美文网首页
Python字典转换为列表

Python字典转换为列表

作者: KangSmit的算法那些事儿 | 来源:发表于2020-06-27 16:37 被阅读0次
    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

    相关文章

      网友评论

          本文标题:Python字典转换为列表

          本文链接:https://www.haomeiwen.com/subject/ajkvfktx.html