Python 字典 clear()方法
2017-10-26 15:47
369 查看
描述
Python 字典 clear() 方法用于删除字典内所有元素。语法
clear() 方法语法:D.clear()
参数
无。返回值
该方法没有任何返回值。实例
以下实例展示了 clear() 方法的使用方法:#!/usr/bin/python3 D = {'Name': 'Zara', 'Age': 7} print ("字典长度 : %d" % len(D)) D.clear() print ("字典删除后长度 : %d" % len(D))
以上实例输出结果为:
字典长度 : 2 字典删除后长度 : 0
相关文章推荐
- python使用clear方法清除字典内全部数据实例
- python中的字典clear方法
- python 字典 clear方法
- python 字典clear()方法
- 在Python中操作字典之clear()方法的使用
- python使用clear方法清除字典内全部数据实例
- 【Python】Python3 字典 clear()方法
- 在Python中操作字典之clear()方法的使用
- Python中字典的增、删、创建、索引与字典方法clear,copy,formkeys,get,has_key,popitem,update
- Python实现合并字典的方法
- python 字符串,列表,字典常用方法
- Python中使用item()方法遍历字典的例子
- Python 字典(Dictionary) items()方法
- Python的“二维”字典 (two-dimension dictionary)定义与实现方法
- Python Sqlite3以字典形式返回查询结果的实现方法
- Python 字典的setDefault()方法
- Python 删除字典元素的4种方法
- Python字典方法copy()和deepcopy()的区别
- Python中字典(dict)和列表(list)的排序方法实例
- Python 字典 update() 方法