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

How to create an empty dictionary in python

王林
Release: 2020-06-09 14:26:00
Original
29059 people have browsed it

How to create an empty dictionary in python

The method to create a dictionary in python is:

Method 1:

my_dict = {}
print(my_dict)
Copy after login

Method 2:

my_dict = dict()
print(my_dict)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template