Python3 字典 clear()方法
Python 3 教程
· 2019-02-06 14:58:01
描述
Python 字典 clear() 函数用于删除字典内所有元素。
语法
clear()方法语法:
dict.clear()
参数
- NA。
返回值
该函数没有任何返回值。
实例
以下实例展示了 clear()函数的使用方法:
#!/usr/bin/python3
dict = {'Name': 'Zara', 'Age': 7}
print ("字典长度 : %d" % len(dict))
dict.clear()
print ("字典删除后长度 : %d" % len(dict))
以上实例输出结果为:
字典长度 : 2 字典删除后长度 : 0
点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html
Letting Go of the Words
Janice (Ginny) Redish / Morgan Kaufmann / 2007-06-11 / USD 49.95
"Redish has done her homework and created a thorough overview of the issues in writing for the Web. Ironically, I must recommend that you read her every word so that you can find out why your customer......一起来看看 《Letting Go of the Words》 这本书的介绍吧!