Python 字典添加项目
字典添加项目
通过使用新的索引键并为其分配一个值来将项目添加到字典中
示例
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["color"] = "red"
print(thisdict)
亲自尝试 »
通过使用新的索引键并为其分配一个值来将项目添加到字典中
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["color"] = "red"
print(thisdict)
亲自尝试 »
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]
If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]