variable
In Python, to store a data, you need to define a variable
number1 = 1 #numbe1 is a variable used to store data: 1
number2 = 2 #number2 is also a variable, used to save data: 2
sum = number1+number2 #sum is also a variable, save the value of 1+2 hard
Description:
The so-called variable: is the amount that can be changed.
Programs are used to process data, and variables are used to store data
Variables in python do not need to specify the type, the system will automatically recognize
Content expansion:
Variable naming
1、 Start with an underscore or uppercase and lowercase letters, followed by any combination of underscores, uppercase and lowercase letters, and numbers (but generally, the beginning of an underscore has a special meaning and is not recommended)
2、 It is recommended to use English words or abbreviations with fixed meanings, such as srv = server, skt = socket, generally based on posix naming rules
3、 Recommended hump writing: Big hump is used to write classes, such as MyFirstLove, small hump such as myFirstLove or posix is used to write variable or function names. Compared with the two, posix is currently recommended, such as: my_first_love
4、 Avoid reserved words and keywords, such as class, def, break, for; (print out all keywords of the system, import keyword; // first cause the keyword module print (keyword.kwlist)//print)
This is the end of this article on how to understand variables in Python. For more information about the meaning of variables in Python, please search ZaLou.Cn
Recommended Posts