一、列表转字典:
方法1:
list_1 = [‘abc‘, ‘efg‘]
list_2 = [123, 456]
new_dict = dict(zip(list_1, list_2))
方法2:
list_1 = [‘a‘, 1]
list_2 = [‘b‘, 2]
list_3 = [list_1, list_2]
new_dict = dict(list_3)
二、字典转列表:
dict_1 = {‘a‘, 1}
list_keys = list(dict_1)
list_values = list(dict_1.values)
原文地址:https://www.cnblogs.com/crazyaugustmoon/p/10189681.html
时间: 2024-11-12 06:16:50