First, the module
SYS Standard library
Import Sysprint (Sys.path) #打印环境变量print (SYS.ARGV)
Prints some paths to the storage address of the Python library.
OS Standard library
Import os# cmd_res = Os.system ("dir") #执行命令, does not save the result cmd_res = Os.popen ("dir"). Read () print ("---->", cmd_res) Os.mkdir ("New_dir")
Third, import module
Look in the current directory first, if not, then go to the environment variable to find
Import Guess
Iv. PYC
__pycache__ Directory
When the Python program runs, the result of the compilation is saved in the Pycodeobject in memory, and when the Python program finishes running, the Python interpreter writes Pycodeobject back to the PYc file.
When the Python program runs for the second time, the program will first look for the PYc file on the hard disk, if found, compare the code time, the code time later, directly loaded, if the code time earlier than the previous process.
If not found, repeat the process above.
V. Types of data
1. Digital
A.int (integral type)
Print (Type (2**32)) print (Type (2**33)) print (Type (2**50)) print (Type (2**100))
B. Float type, float
Print (Type (52.3E4)) print (Type (52.3E-4))
C. Boolean value
True or False
True or False
1 or 0
Data operations
1. Arithmetic operations:
+-*/, subtraction
% modulus, remainder
* * Power, exponentiation
The integer part that returns the quotient.
2. Comparison operation:
= =, equal to
! =, not equal to, in Python 2.x sometimes this means:<>
, <, >=, <=
3. Assignment operation
=,+=,-=,*=,/=,%=,**=,//=
4. Logical operation
And,or,not
With, or, non-
5. Member Operations
In,no in
6. Identity operations
Is,is not
A = [1,2,3,4]print (type (a)) b = Type (a) is Listprint ("B:", b) c = Type ("333") is Strprint ("C:", c) d = Type ("333") was not STRPR Int ("D:", D)
7. Bit arithmetic
&, bitwise with, and, two are all 1, take 1, other cases take 0
|, bitwise OR, or, any one of them is 1, fetch 1, other cases take 0
^, bitwise XOR, different 1, same as 0
~, bitwise reverse, first reverse (0 change to 0), minus 256
<<, move left, shift right one, multiply by 2, move right two, multiply (2*2)
>>, move right, shift right one, divide by 2, move right two, divide by (2*2)
Six or three-dollar operation
result = value 1 if condition else value 2
If the condition is true: result = value 1
If the condition is false: result = value 2
Vii.. Binary
Binary, octal, decimal, hexadecimal
Eight, bytes
Text is always Unicode, represented by the STR type, and binary data is represented by the bytes type
msg = "I love Beijing Tian ' an gate" print (msg) print (Msg.encode (encoding= "Utf-8")) Print (Msg.encode (encoding= "Utf-8"). Decode (encoding= " Utf-8 "))
Python Course day2