There are six basic data types of python3: Number (int, float, bool, complex), String, List, Tuple, Dictionary, Set
Variable Data types: list, dic, set
Immutable data types: Number, String, Tuple
What are variable data types and immutable data types?
1. The immutable data type in Python does not allow the value of the variable to change. If the value of the variable is changed, it is equivalent to creating a new object. For objects with the same value, there is only one object in the memory, and there is an internal reference count to record how many variables refer to this object.
2. The variable data type in Python allows the value of the variable to change. If the variable is appended, =, etc., it will only change the value of the variable without creating a new object. The address of the object referenced by the variable will not change either. However, for different objects with the same value, there will be different objects in the memory, that is, each object has its own address, which is equivalent to saving multiple copies of the object with the same value in the memory. There is no reference counting here. Real objects.
The above is the detailed content of What are the variable data types in Python?. For more information, please follow other related articles on the PHP Chinese website!