首页
mac
it
登录
6mi
u
盘
搜
搜 索
it
python中两个列表形成dict,要确保作为key的list的值,最好是没有重复的
python中两个列表形成dict,要确保作为key的list的值,最好是没有重复的
mac
2024-03-20
30
# 比较好奇如果两个list想要生成一个dict,但是作为key的list有重复的情况下,会发生什么? name_list=["yun","li","guo",'yun','yun'] score_list=['90','80','90','70','100'] target_dict=dict(zip(name_list,score_list)) print(target_dict)
在key值有重复的情况下,字典中的值,将会使用列表中对应的最后一个值作为value
转载请注明原文地址: https://mac.8miu.com/read-486711.html
最新回复
(
0
)