Python Basic Learning Notes
One, Python data type:
1. Number Type
(1) Boolean type
(2) integral type
(3) floating point number
2. Sequence Type
(1) string
(2) meta-group
(3) List
3. Image Type
(1) Dictionary
4. Collection type
(1) Variable set
(2) immutable set
Second, Python annotation method
1. Single-line Comment
Make a single line comment with "#"
# This is a line of Python comments
2, multi-line Comment
Multi-line comments are annotated with a pair of three single quotes
"This is a python multiline comment"
Three, character encoding
1.Assic: Use 8-bit length to save one character
the Ord () function can see the Assic code of a character
2.Unicode: Use 16-bit length to save one character
3,UTF-8: variable length, 3 bytes of a Chinese character
A= ' abc ' is saved with Assic at this time B=u ' abc ' is saved with Unicode
Iv. Import Module
1. OS module
the OS module can be used for system management, which can be used to execute system commands, which returns the results of command execution, 0 for success, and other numbers for failure
The Os.walk.next () method can output the directory tree sequentially
2. Commands Module
The commond.getstatusoutput () method returns a tuple with the command's execution result, the output of the command already
3, the method of importing the module is:
Import Module name //This imports all methods of the module
from Module name Import method name//This imports the method under the module
Import module name as new module name//This will rename the module when the module is imported
V. User interaction
1. Input () function:
The input () function is processed according to the input content type, and the input number is the type of the number, which is the string type.
2. Raw_input () function:
The Raw_input () function, all of the content entered by the function is treated as a string.
Vi. Process Control
1. Judgment
If ...:
...
elif ...:
...
Else:
...
2. For Loop
For i in {range}:
...
3. While Loop
While ...:
...
Else:
...
This article is from the "Artisan" blog, please be sure to keep this source http://8838848.blog.51cto.com/8828848/1721550
Python Basic Learning Notes