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://codercto.com/courses/l/10.html
Learning PHP, MySQL, JavaScript, and CSS
Robin Nixon / O'Reilly Media / 2012-9-3 / USD 39.99
If you're familiar with HTML, you can quickly learn how to build interactive, data-driven websites with the powerful combination of PHP, MySQL, and JavaScript - the top technologies for creating moder......一起来看看 《Learning PHP, MySQL, JavaScript, and CSS》 这本书的介绍吧!