One .python 2 .X VS 3.X
1. 2.x = Default encoding =ASSIC = I won't support it ,3.x = Default encoding =UNICODE = Chinese is supported by default
2. 3.x Are not compatible 2.x 3.3.x Core grammar adjustments , Easier to learn 4. The new feature defaults to 3.x There are
Two . Variable
In order to store some intermediate points in the operation of the program result , In order to facilitate future calls ,python The variable name is represented in lowercase , Upper case means constant name
# Variable in lowercase age = 27 # Constant in uppercase NAME = xiaoming
Naming rules for variables
1. Be descriptive ( for example :myage) 2. Variable names can only be , Numbers , Alphabetic composition , It can't be spaces or special characters (#?<.,¥$*!~) 3. Cannot use Chinese as variable name 4. Cannot start with a number 5. Reserved characters cannot be used
3、 ... and . code
The first table that supports Chinese is called GB2312
1980 The year was born gb2312 6700+
1995 The year was born gbk1.0 20000
2000 The year was born gb18030 27000
unicode unicode Support coding for all countries and regions
UTF-8 = unicode The extended set of , Variable length character coding set
Code evolution process
Assic -->Gb2312 ->gbk1.0-->gb18030
Assic -->unicode -->utf-8 /utf-16
Python2.x == Assic Default encoding , You need to start writing code , Define the encoding type #!-- coding:utf-8 -- perhaps #coding:utf-8
#!-*- coding:utf-8 -*-
python3.x == unicode Default encoding
unicode It's downward compatible gb2312 , gbk
Four . notes
Single-line comments use #
#str string = character string To convert data into a string, use str( Transferred data ) print("You can still live for " + str(death_age - int(age)) +" years ....")
Multiline comments use three single quotes or three double quotes ''' Annotated content '''
''' if guess_age == age_of_princal then print("yes") else print("no ") '''
author : Empty bad uncle Blog
One 、MATLAB Find the approxima