python 内建函数 zip
程序员文章站
2022-06-19 10:48:53
key = [key for key in dict(zip(('a','b','c','d','e'),(1,2,3,4,5))) ] print(key) ['a', 'b', 'c', 'd', 'e'] A0 = dict(zip(('a','b','c','d','e'),(1,2,3,4 ......
key = [key for key in dict(zip(('a','b','c','d','e'),(1,2,3,4,5))) ] print(key) -------------------------------------------------------- ['a', 'b', 'c', 'd', 'e']
a0 = dict(zip(('a','b','c','d','e'),(1,2,3,4,5))) a1 = range(10) a2 = [i for i in a1 if i in a0] a3 = [a0[s] for s in a0] a4 = [i for i in a1 if i in a3] a5 = {i:i*i for i in a1} a6 = [[i,i*i] for i in a1] ------------------------------------------------------------- a0 = {'a': 1, 'c': 3, 'b': 2, 'e': 5, 'd': 4} a1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] a2 = [] a3 = [1, 3, 2, 5, 4] a4 = [1, 2, 3, 4, 5] a5 = {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81} a6 = [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]]
本文首发于python黑洞网,博客园同步跟新
上一篇: Fragment实现底部导航栏