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

查看所有标签

Deep Learning

Deep Learning

Ian Goodfellow、Yoshua Bengio、Aaron Courville / The MIT Press / 2016-11-11 / USD 72.00

"Written by three experts in the field, Deep Learning is the only comprehensive book on the subject." -- Elon Musk, co-chair of OpenAI; co-founder and CEO of Tesla and SpaceX Deep learning is a for......一起来看看 《Deep Learning》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具