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