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://www.codercto.com/courses/l/8.html

查看所有标签

Rework

Rework

Jason Fried、David Heinemeier Hansson / Crown Business / 2010-3-9 / USD 22.00

"Jason Fried and David Hansson follow their own advice in REWORK, laying bare the surprising philosophies at the core of 37signals' success and inspiring us to put them into practice. There's no jarg......一起来看看 《Rework》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

随机密码生成器
随机密码生成器

多种字符组合密码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具