(1)过滤掉长度小于3的字符串列表,并将剩下的转换成大写字母
lst = ["alex", 'db', '2b', "wusir", 'sb', "taibai","nezha", "ritian"]
print([ el.upper() for el in lst if len(el) >= 3])
求(x,y)其中x是0-5之间的偶数,y是0-5之间的奇数组成的元祖列表
print([(y, x) for x in range(6) for y in range(6) if y %2==0 and x%2==1 ])
print([(i, j) for i in range(0,6,2) for j in range(1,6,2)])
# (3) 求M中3,6,9组成的列表M = [[1,2,3],[4,5,6],[7,8,9]]
# M=[3,6,9]
# lst = [(el-2,el-1,el) for el in M]
# print(lst)
# (4) 求出50以内能被3整除的数的平方,并放入到一个列表中。
# lst = [i*i for i in range(50) if i %3 ==0]
# print(lst)
# (5) 构建一个列表:
# ['python1期', 'python2期', 'python3期', 'python4期', 'python6期', 'python7期', 'python8期', 'python9期', 'python10期']
# lst = ['python%s期' % i for i in range(1,11)]
# print(lst)
# (6) 构建一个列表:[(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6)]
# lst =[(x,x+1) for x in range(6) ]
# print(lst)
# (7) 构建一个列表:[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
# lst = [i for i in range(19) if i%2==0]
# print(lst)
# (8) 有一个列表l1 = ['alex', 'WuSir', '老男孩', '太白']
# 将其构造成这种列表['alex0', 'WuSir1', '老男孩2', '太白3']
# l1 = ['alex', 'WuSir', '老男孩', '太白']
# lst = [l1[i]+str(i) for i in range (len(l1))]
# print(lst)
x = {
# 'name':'alex',
# 'Values':[{'timestamp':1517991992.94,
# 'values':100,},
# {'timestamp': 1517992000.94,
# 'values': 200,},
# {'timestamp': 1517992014.94,
# 'values': 300,},
# {'timestamp': 1517992744.94,
# 'values': 350},
# {'timestamp': 1517992800.94,
# 'values': 280}
# ],}
print([[el['timestamp'], el['values']] for el in x['Values']])