Variables in 1,python language differ from other language variables
Variable-------------> Exactly what is changing???
>>> x=12 x points to the memory unit where 12 is located
>>> y=13 y points to the memory unit where 13 is located
>>> Print X
12
>>> Print Y
13
In Python, a variable is a small tag of a piece of memory
X=y means that x points to a memory unit that points to Y (similar to a pointer in C), so you cannot modify the data that it points to a memory cell by using a variable, and you can change its point by assigning a value.
The variable is the memory point, not the data it points to.
>>> x=12
>>> x=13
>>> print x The data in the memory unit pointed to by 12 is still 12
13
>>> x=13
>>> ID (x)
37841736 (Memory tab 1)
>>> x=12
>>> ID (x)
37841760 (Memory tab 2)
>>> y=13-------give Y the address in the memory unit where 13 is located, that is, the memory unit where Y points to 13
>>> ID (y)
37841736 (Memory label 3 and memory label 1 same)
X=y principle: X---->| 12
Y---->|-------13
In the C language, the variable allocates memory address once
In Python, when a new variable is generated, the newly allocated memory stores the data and modifies the data of the variable to point to the x=100
No data type of variable in 2,python
What type of value is assigned, and what type is the variable?
>>> x=12
>>> type (x)
<type ' int ' >
>>> y=12.5
>>> type (y)
<type ' float ' >
>>> z= ' www.baidu.com '
>>> type (z)
<type ' str ' >
The four-story Python variable parsing