Module : Encapsulated function, also known as library
- Standard library: No installation required, can be directly imported, such as: sys, OS. Note: The import library name is not the same as the current file name
- Third party libraries: need to download the installation, in order to use
Example:
Import SYS Import OS Print # Print Environment Variables Print # prints the path of the current script, the absolute path is printed in Pycharm, and the relative path is printed in cmd # View all files in the current directory Note: Execution can be output to the screen, but will not be stored res=os.system ("dir") Print# printing results of 0
Attention:
- Import the xx.py file, and when you execute the script, it will be executed directly xx.py
- Files can be directly import under the same path
- If you create a new path, you can place it in an environment variable; or place the file directly in the folder that the environment variable refers to
Data operations
Mathematical operators: +-*/* (Power)% (modulo, returns the remainder of the division; common for odd pages even)//(divisible, returns the integer part of the quotient)
Conditional operator: = = = = <> > < >= <=
Assignment operator: = = = = *=/=%= **=//=
Logical operators: And Or not (for example: not 1==1)
Member operators: in Not IN (for example: if 1 in [1, 2, 3, 4])
Identity operator: is isn't (for example: a=[1,2,3,4] If Type (a) is list:)
Bitwise operators: & (bitwise VS: A&B) | (bitwise OR) ^ (bitwise XOR, XOR: Difference is 1, otherwise 0) ~ (bitwise Reversed) << (shift left) >> (shift right)
Ternary operators:
A, B, C=1, 3, 5
D=a if a>b else C #如果a >b is true, then D is assigned a, otherwise D is assigned C
Python 0 Basic Learning-Fundamentals 3-modules, data types and calculations