list1 = ["a", "b", "c","d"]
list2 = [1,2,3,4]
a = [ x for x in list1]
生成器
b = (x for x in list1)
print(next(b))
列表映射
c= zip(list1,list2)
print(c)
for i in c:
print(i)
元祖转化字典
tuplex = ((2, "w"),(3, "r"))
print(dict((x, y) for x, y in tuplex))
两字典合并
dic1 = {2: 'w', 3: 'r'}
dic2 = {6: 'rhiu', "wee": 'hui'}
def Merge(dict1, dict2):
res = {**dict1, **dict2}
print(res)
return res
Merge(dic1,dic2)
网友评论