Python 字典(Dictionary) clear()方法
Python 教程
· 2019-02-03 06:44:39
描述
Python 字典(Dictionary) clear() 函数用于删除字典内所有元素。
语法
clear()方法语法:
dict.clear()
参数
- NA。
返回值
该函数没有任何返回值。
实例
以下实例展示了 clear()函数的使用方法:
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7};
print "Start Len : %d" % len(dict)
dict.clear()
print "End Len : %d" % len(dict)
以上实例输出结果为:
Start Len : 2 End Len : 0
点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html
Concepts, Techniques, and Models of Computer Programming
Peter Van Roy、Seif Haridi / The MIT Press / 2004-2-20 / USD 78.00
This innovative text presents computer programming as a unified discipline in a way that is both practical and scientifically sound. The book focuses on techniques of lasting value and explains them p......一起来看看 《Concepts, Techniques, and Models of Computer Programming》 这本书的介绍吧!