What is dict in python?
dict is a variable data type in python, use { } means that the key of dict must be an immutable data type, while the data type of value can be arbitrary.
Format:
{key:value,key:value,key:value}
Note: If the key-value pair is a string, use single quotes, and the last key-value pair does not have a comma.
Advantages of dict:
①: Fast query speed, binary search possible
②: Key cannot be repeated
Note:
Immutable data types: tuple, bool, int, str can hash
Variable data types: dict, list, set
Related recommendations:《 Python Tutorial》
The above is the detailed content of What is dict in python. For more information, please follow other related articles on the PHP Chinese website!