1. Install the Python environment under Windows installation PYTHON-3.6.3RC1-AMD64, and then install the Python development tools Pycharm.
Experience: much simpler than Java
1.1, install the Excel library, use the PIP command to install under Windows cmd: Pip install XLRD, the system will automatically download and install the ELRD library. Or, download the installation in Pycharm using the Plugins manager.
Experience: very simple.
2, Character set
ASCII 255 characters without Chinese 7 bit, single byte
Bg2312-80 7445-Character compatible ASCII 16-bit, double-byte
BIG5 13053-Character compatible ASCII 16-bit, double-byte
BG18030 27484 character compatible ASCII single byte partially compatible ASCII, double byte, four byte
Unicode-compatible ASCII 16-bit, double-byte, unified GB18030 and BIG5 and ASCII
One usage of UTF-8 Unicode 16 binary, variable length, ASCII using 1 bytes, Greek, accented text with 2 bytes, kanji using 3 bytes, auxiliary flat characters using 4 bytes
3,2 in the system
The sum of each digit represented by the preceding digit +1
0 0
1 1
2 Ten
3 11
4
5 101
6 110
7 111
8
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
16 10000
4, variable and print format output
2.1, the first format control method, with%s to do the placeholder control
Name=input ("Name:")
Age =int (Input ("Age:"))
Print (Type (age))
Job =input ("Job:")
Salary=input ("Salary:")
Print (Type (salary))
info = ""
--------Info of%s---------
name:%s
age:%d
job:%s
salary:%s
"% (name,name,age,job,salary)
Print (info)
Advantages:
Cons: Not intuitive, difficult to maintain
Note: The data type of the input () function is string and must be cast to be other types
"or" "effect is the same, representing multiple lines of string or multiple lines of comment
Try not to use this method unless you have to
%d indicates that only numeric integers are received, and other types of characters enter an error
%f indicates that only numeric floating point is received, other types of character input error
2.2, the second format control mode, the Format function
Info2= ""
-----info of {_name}-----
Name:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
". Format (_name=name,_age=age,_job=job,_salary=salary)
Advantages: Intuitive, simple and easy to maintain
Disadvantages:
Note: Print the variable name and the original variable name as far apart as possible
There is a "." in front of format, (variable assignment)
2.3, third format control mode, using digital Placeholder control format
Info3= ""
------info of {0}------
NAME:{0}
Age:{1}
JOB:{2}
SALARY:{3}
". Format (name,age,job,salary)
Print (INFO3)
Advantages:
Cons: Not intuitive, maintainability is better than the first way, but not as good as the second
5,python notes
#单行注释
"", "" "Multiline comment, also multi-line string setting" '------info of {0}------
NAME:{0}
Age:{1}
JOB:{2}
SALARY:{3}
‘‘‘
6,Import module
It can appear anywhere in the program.
Import Module
Keyword Module name
If you want to import multiple modules at the same time, you only need to delimit them with commas before the module name:
Import Module1,module2,module3 .....
It is best to follow this sequence when importing a module with an import statement: 1, Python standard library module
2. Python third-party module
3. Custom Modules
From module (block name) import name (function name)
Imports the specified function of the specified module
_username = "Cat"
_password = "a"
Username = input ("Username:")
Password = input ("Password:")
If username = = _username and Password = = _password:
Print ("Oye". Format (Name=username))
Else
Print ("Fuck off baby!")
Print (username, password)
Attention:
= = means exactly equal to
! = Indicates not equal to
The Python language strictly adheres to indentation, if the indentation error, then the system error
A direct reference to a variable is implemented through the input variable name within {}, for example {name}
8, loop, while, for
8.1 For Loop
Age_of_you=45
For I in range (3):
Gass_age=int (Input ("Gassage:"))
If gass_age==age_of_you:
Print ("Oye")
Break
Elif gass_age<age_of_you:
Print ("Too small")
Else
Print ("Too big")
Else
Print ("Try too many times". Fuck off ")
Attention:
Break: Exits the current logical block, such as If,for,while
The else syntax of while,for is Python-unique
Count=count+1 in Python medium-effect and count+=1
Range (10,x) X is step, default is 1, you can not enter
Age_of_you=45
Count=0
While count<3:
Gass_age=int (Input ("Gassage:"))
If gass_age==age_of_you:
Print ("Oye")
Break
Elif gass_age<age_of_you:
Print ("Too small")
Else
Print ("Too big")
Count+=1
If Count ==3:
Countine_confirm=input ("Agein? y| N: ")
If countine_confirm! = "N":
Count=0
Else
Print ("Thank You")
8.3,continue
For I in range (20):
If I <10:
Print ("Loop:", i)
Else
Continue
Print (i)
Note: Continue skips this cycle and goes directly to the next loop
First knowledge of Python