如何修改Python中的字典

我想使用Python修改这些数据


{

    "date":<curdate>,

    "name":["","",""],

    "id":[",","]

}


{

    "date":<currdate>,

    "inputs":{

        "name":["","",""], 

        "id":[",","]

    }

}


慕容708150
浏览 91回答 1
1回答

慕尼黑5688855

只需将字典元素分配给新字典中的适当元素即可。new_dict = { "date": old_dict["date"],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"inputs": {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name": old_dict["name"],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "id": old_dict["id"]&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python