English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python basic tutorial

Python flow control

Python Functions

Python Data Types

Python file operations

Python objects and classes

Python date and time

Python advanced knowledge

Python reference manual

Python dictionary methods

A dictionary is a key/Value (key/A collection of (key, value) pairs. Python has many methods for dictionaries. On this reference page, you will find all the methods for using dictionaries.

MethodDescription
clear()Delete all elements in the dictionary
copy()Return a copy of the dictionary
fromkeys()Return a dictionary with the specified key and value
get()Return the value of the specified key
items()Return a list of tuples containing each key-value pair
keys()Return a list containing all dictionary keys
pop()Delete the element with the specified key
popitem()Delete the last inserted key-value pair
setdefault()Return the value of 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

In our Python dictionary tutorial Learn more about dictionaries in Chinese.