Python 字典方法

Python 有一组可以在字典上使用的内建方法。

Method Description
clear() Remove all elements from the dictionary
copy() Return a copy of the dictionary
fromkeys() Return a dictionary with the specified key and value
get() Return the value associated with the specified key
items() Return a list of tuples containing each key-value pair
keys() Return a list containing all the keys in the dictionary
pop() Remove the element with the specified key
popitem() Remove the last inserted key-value pair
setdefault() Return the value associated with the specified key. If the key does not exist, insert a key with the specified value.
update() Update the dictionary with the specified key-value pairs
values() Return a list of all values in the dictionary

A Koyarar Python Dictionary A koyar da yadda za a iya koyar da zikin dake a Python