zoukankan      html  css  js  c++  java
  • 寻找特定的值

     1 #!/usr/bin/env python
     2 # -*- coding: utf-8 -*-
     3 #查找列表中元素,移除每个元素的空格,并查找以 a或A开头 并且以 c 结尾的所有元素
     4 #先转换为字符串
     5 li = ["alec", " aric", "Alex", "Tony", "rain"]
     6 tu = ("alec", " aric", "Alex", "Tony", "rain")
     7 dic = {'k1': "alex", 'k2': ' aric',  "k3": "Alex", "k4": "Tony"}
     8 
     9 for z in li:
    10     x = str(z.strip())
    11     if x.startswith('a') or x.startswith('A') and x.endswith('c'):
    12         print(x)
    13 for a in tu:
    14      s = str(a.strip())
    15      if s.startswith('a') or s.startswith('A') and s.endswith('c'):
    16          print(s)
    17 #newdic = {}
    18 for d,v in dic.items():
    19     if v.startswith('a') or v.startswith('A') and v.endswith('c'):
    20         print(v)
    21     #print(d,v)
    22 for f in dic.values():
    23     if f.startswith('a') or f.startswith('A') and f.endswith('c'):
    24         print(f)
  • 相关阅读:
    buuctf—web—高明的黑客
    buuctf—web—Easy Calc
    buuctf刷题之旅—web—EasySQL
    buuctf刷题之旅—web—随便注
    buuctf刷题之旅—web—WarmUp
    Dao
    Spring AOP配置
    分布式
    tomcat配置
    JVM知识
  • 原文地址:https://www.cnblogs.com/Bruce-yin/p/6815558.html
Copyright © 2011-2022 走看看