Python字典转换为列表

2020-06-27  本文已影响0人  KangSmit的算法那些事儿
dict1={"战将姓名": "战将战力",
"吕布": 100,
"张飞": 98,
"马超": 97,
"关羽": 97,
"许褚": 96,
"赵云": 96,
"典韦": 95,
"文丑": 94,
"甘宁": 94,
"庞德": 94,
"太史慈": 94,
"黄忠": 93,
"颜良": 93,
"孙策": 93,
"张辽": 93,
"魏延": 92,
"华雄": 92,
"文鸳": 92,
"周泰": 91,
"夏侯渊,": 91,
"孙坚": 90,
"徐晃": 90,
"夏侯敦": 90,
"曹彰": 89,
"姜维": 89,
"张颌": 89,
"凌统": 89,
"吕玲绮": 88,
"马云隶": 88,
"关索": 88}

dictlist=[]
for keys, value in dict1.items():
  temp = [keys,value]
  dictlist.append(temp)
dictlist

执行结果:


image.png
上一篇下一篇

猜你喜欢

热点阅读