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

查看所有标签

Neural Networks for Applied Sciences and Engineering

Neural Networks for Applied Sciences and Engineering

Samarasinghe, Sandhya / CRC Pr I Llc / 2006-9 / $ 118.59

In response to the exponentially increasing need to analyze vast amounts of data, Neural Networks for Applied Sciences and Engineering: From Fundamentals to Complex Pattern Recognition provides scient......一起来看看 《Neural Networks for Applied Sciences and Engineering》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具