Python字典方法

120 阅读1分钟
方法名称方法描述
[dict.clear()](https://blog.finxter.com/python-dictionary-clear/ "Python Dictionary clear()")删除字典中的所有元素
[dict.copy()](https://blog.finxter.com/python-dict-copy-method/ "Python dict.copy() Method")创建一个字典的浅层拷贝
[dict.fromkeys()](https://blog.finxter.com/python-dict-fromkeys-method/ "Python dict.fromkeys() Method")从一个给定的可迭代的键中创建一个新的 dictionary
[dict.get()](https://blog.finxter.com/python-dict-get-method/ "Python dict.get() Method")返回与一个相关的,如果键不存在,则返回默认值
[dict.items()](https://blog.finxter.com/python-dict-items-method/ "Python dict.items() Method")输出一个 dictionary 的 (key, value)元组 对的列表
[dict.keys()](https://blog.finxter.com/python-dict-keys-method/ "Python dict.keys() Method")输出一个 dictionary 的所有键,作为dict_keys() iterable 对象。
dict.pop()
dict.popitem()
dict.setdefault()
dict.update()
dict.values()

The postPython Dictionary Methodsfirst appeared onFinxter.