list1 = [1,2,3,4,5]
list2 = ["hello","kity","josn","kangkang","jian"]
dict1 = dict(zip(list1,list2))
print(dict1)
看效果:
注意:
1、作为键值的列表写在参数前
2、len(dict1) == min(len(list1),len(list2))
dict2 = {1: 'hello', 2: 'kity', 3: 'josn', 4: 'kangkang', 5: 'jian'}
list1 = [key for key in dict2.keys()]
print(list1)
list2 = [value for value in dict2.values()]
print(list2)