Python 字典 clear() 方法
示例
从 car
列表中移除所有元素
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
car.clear()
print(car)
亲自尝试 »
定义和用法
The clear()
方法会移除字典中的所有元素。
语法
dictionary.clear()
参数值
没有参数
从 car
列表中移除所有元素
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
car.clear()
print(car)
亲自尝试 »
The clear()
方法会移除字典中的所有元素。
dictionary.clear()
没有参数
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]