First, the Python Module Library Classification python Module library mainly divided into two categories, one is the official standard library, the other is a three-party library. The official standard library does not require the user to do special installation can be used, three-party library similar plug-in requires users to download the corresponding tripartite library to use. General official Standard library will be installed under the path label \\*\\python\\python36\\lib, the three-party library will be installed in *\\python\\py thon36\\lib\\site-packages. Ii. Introduction to Modules os, SYS, Getpassgetpass python call modules or scripts can use the import command directly, Specific forms such as: import os, if you call more than one module can be written import os,sys,getpass can be. In addition, when invoking a script in a three-party or official library through the import command, it is important to note that the script written by the author cannot have the same name as the calling script, otherwise it cannot be called. The order of the library or module invocation is the first call to the module or script under the same path, and if no relevant script or path under the same path is found in the program's library for the script or module, If you need to invoke a script that does not exist in the above location, you need to modify the environment variable to implement it. 2.1 sys.path[] Command Introduction sys.path[] is a Python search module path set, is a list, you can use the print (Sys.path) output, sys.path the path to the default output environment variable. 2.2 sys.argv[] Command Introduction sys.argv[] is used to get command line arguments, you can use the print (SYS.ARGV) output, SYS.ARGV The default output is a relative path, but this command is called in PycharmThe absolute path is played. The reason for this is that Pycharm software implicitly defines the relative path of the command as an absolute path, and this behavior is not related to the PYTHON3 interpreter. 2.3 os Command Introduction The os module contains common operating system features, regardless of the specific platform. os.system () is equivalent to CMD in Winddows and HyperTerminal under Linux. The specific usage content is os.system (' + Operations commands ') such as Os.system (' ipconfig '), Os.system (' dir ') and so on. The os.system () command has a special, which outputs the results to the screen when working, but prints the order via the Print command , then only feedback 0, or 1.0 for the command to execute successfully, 1 for the command output. If you need to print out the results of the operation need to resolve it through the Os.popen.read () command. It works by printing to the temporary memory of the system through the actions that the Os.popen command will display, and then taking the results out of the temporary memory through the Os.read () command. os.popen.read () Effect of =os.popen () +os.read () The effect of the third, what is pyc in Python python is an interpreted language, and Python works by the time the Python program executes saves the compilation results in the Py codeobject of the memory type. When the Python program finishes running, the Python interpreter writes Pycodeobject back to the PYc file. python each call will be preferred to find the interpreter corresponding to the PYc file for execution, if there is no corresponding PYC file or corresponding PYc file &The nbsp; property is not the most, and the Python interpreter compiles it again. Iv. Types of data
| Type |
Example |
int integral type
|
1, 2, 3, 4, 5, 6 |
| Long integer type |
Python3 in the Python2 to identify a specific value in the |
| float Float Type |
3.14 10**3 |
| Complex plural |
3+4j |
| Name |
Type |
Results |
| Boolean true |
1 |
Ture |
| Boolean Fake |
0 |
False |
Five, operational symbols
| Operation symbols |
Name
|
Description |
Example |
+
|
Add |
Two objects added
|
3+4 Get 7,a+b Get AB |
| - |
Reducing |
Subtract or get a complex number of two objects |
4-3 Get 1,-5.2 |
| * |
By |
Two objects multiply or return an object value that is repeated several times |
2*3 get ' aaa ' for 6 ' a ' |
**
|
Power |
Returns the Y power of X |
3**4 equivalent to 3*3*3*3
|
| / |
Except |
x divided by Y
|
4/3 integer division Get integer result, decimal division get decimal |
| // |
Take an integer
|
Returns the integer part of the quotient |
4//3 gets 1 |
| % |
Take the mold
|
Returns the remainder of a division |
8%3 Get 2-25.5%2.25 Get 1.5 |
| << |
Move left |
Shifts a number of bits to the left by a certain number (each number represents a bit bit or a binary number in memory) |
2<<2 gets 8--2 per bit as 10 |
| >> |
Move right |
Shifts a number of bits to the right by a certain number (each number represents a bit bit or a binary number in memory) |
8>>2 gets 2--10 per bit as 2 |
| & |
Bitwise-AND |
Number of bitwise AND
|
5&3 gets 1
|
|
|
Bitwise OR |
The number of bitwise OR
|
5|3 gets 7 |
| ^ |
Bitwise XOR OR |
The bitwise XOR of the number |
5^3 gets 6 |
| ~ |
Rollover by bit |
The bitwise reversal of X is-(x+1) |
-6 |
| < |
Less than |
Returns whether x is less than Y. All operators return 1 for true, and return 0 for false distinction and true,false equivalence |
5<3 returns False if two operands are numbers, they are first converted to a common type, otherwise they are always false.
|
| > |
Greater than |
Returns whether x is greater than Y |
5>3 returns True if two operands are numbers, they are first converted to a common type, otherwise they are always false. |
| <= |
Less than or equal |
Returns whether x is less than or equal to Y |
X=3,y=6 X<=y Returns True
|
| = |
Greater than or equal |
Returns whether x is greater than or equal to Y |
X=6,y=3 X>=y Returns True |
==
|
Equals |
Compare objects for Equality |
x=2,y=2 X=y Returns True
|
| !=/<> |
Not equal to |
Compare objects are not equal |
X=2,y=3 x!=y returns True |
| Not |
Boolean ' Non ' |
If x is true, returns False if X is False, returns true |
X=true, return False
|
| and |
Boolean ' and ' |
Returns the computed value of y if X is false,x and Y returns false |
X=false,y=true, x and Y, because X is false, returns false, where Python does not calculate Y, because it knows that the value of this expression is definitely False. This phenomenon is called short-circuit phenomenon.
|
| Or |
Boolean ' or ' |
If x is true, it returns true, otherwise it returns the value of Y |
X=true, Y=false, x or Y returns True. The short-circuit calculation is also used here. |
Assignment operation:
| Operator |
Describe |
Example |
| = |
A simple assignment operation |
C=a+b assigns the result of the a+b operation to C |
| += |
Addition assignment operator |
C+=a equivalent to C=c+a |
| -= |
Subtraction assignment operator |
C-=a equivalent to C=c-a |
| *= |
Multiplication assignment operator |
C*=a equivalent to C=c*a |
| /= |
Division assignment operator |
C/=a equivalent to C=C/A |
| %= |
Modulo assignment operator |
C%=a equivalent to C=c%a |
**=
|
Power assignment operator
|
C**=a equivalent to C=c**a |
//=
|
Take the divisible assignment operator |
C//=a equivalent to c=c//a |
Ternary 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
Example: a,b,c=1,2,3 d=a if a>b else C result is d=3
This article is from the "Learning Notes" blog, so be sure to keep this source http://demonlg.blog.51cto.com/7229680/1973933
The Day2 of Python learning