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)
自己动手试一试 »
如果您想将 W3Schools 服务用于教育机构、团队或企业,请发送电子邮件给我们
sales@w3schools.com
如果您想报告错误,或想提出建议,请发送电子邮件给我们
help@w3schools.com