The method to create a dictionary in python is:
Method 1:
my_dict = {} print(my_dict)
Method 2:
my_dict = dict() print(my_dict)
Dictionary It is also a commonly used data structure provided by Python, which is used to store data with mapping relationships.
The dictionary is equivalent to saving two sets of data, one of which is key data and is called key; the other set of data can be accessed through key and is called value.
Since the key in the dictionary is very critical data, and the program needs to access the value through the key, the keys in the dictionary are not allowed to be repeated.
Recommended tutorial: python tutorial
The above is the detailed content of How to create an empty dictionary in python. For more information, please follow other related articles on the PHP Chinese website!