Python dict clear()从字典中删除所有项。
dict.clear()
此方法不返回任何值。
链接:https://www.learnfk.comhttps://www.learnfk.com/python/dictionary-clear.html
来源:LearnFk无涯教程网
以下示例显示clear()方法的用法。
#!/usr/bin/python dict={'Name': 'Learnfk', 'Age': 7}; print "Start Len : %d" % len(dict) dict.clear() print "End Len : %d" % len(dict)
当无涯教程运行上面的程序时,它产生以下输出-
Start Len : 2 End Len : 0
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕