Python 的 dict.clear()
方法從字典中刪除所有項目。
參數
無參數。
返回值
None
例子
要從字典 car
中刪除所有項目:
car = {
"manufacturer": "Toyota",
"model": "Prius",
"year": 2018
}
car.clear()
print(car)
{}
相關用法
- Python Dictionary clear()用法及代碼示例
- Python Dictionary copy()用法及代碼示例
- Python Dictionary copy方法用法及代碼示例
- Python Dictionary popitem方法用法及代碼示例
- Python Dictionary fromkeys方法用法及代碼示例
- Python Dictionary setdefault方法用法及代碼示例
- Python Dictionary update()用法及代碼示例
- Python Dictionary setdefault()用法及代碼示例
- Python Dictionary get方法用法及代碼示例
- Python Dictionary values方法用法及代碼示例
- Python Dictionary items方法用法及代碼示例
- Python Dictionary keys方法用法及代碼示例
- Python Dictionary pop()用法及代碼示例
- Python Dictionary popitem()用法及代碼示例
- Python Dictionary has_key()用法及代碼示例
- Python Dictionary get()用法及代碼示例
- Python Dictionary items()用法及代碼示例
- Python Dictionary update方法用法及代碼示例
- Python Dictionary values()用法及代碼示例
- Python Dictionary keys()用法及代碼示例
- Python Dictionary pop方法用法及代碼示例
- Python Dictionary fromkeys()用法及代碼示例
- Python Django Distance用法及代碼示例
- Python Django Distance.unit_attname用法及代碼示例
- Python Django Distance.__getattr__用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 Python Dictionary | clear method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。