Home>Article>Backend Development> How to create an empty dictionary in python

How to create an empty dictionary in python

王林
王林 Original
2020-06-09 14:26:00 28927browse

How to create an empty dictionary in python

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn