First, arithmetic operators
Arithmetic operators |
Assignment operators |
Specific description |
Example |
Add |
+ |
+= |
Additive operations |
|
X+=1 equivalent to X=x+1 |
- |
-= |
Subtraction operation |
|
All assignment operators ibid. |
* |
*= |
Multiplication operations |
|
|
/ |
/= |
Division operation |
|
|
% |
%= |
Modulo arithmetic |
|
|
** |
**= |
Power operation |
2**3=8 |
|
// |
//= |
The integer operation |
9//2=4 |
|
Two-bit operators
Bitwise operators |
Specific description |
& |
Bitwise AND operation, 1&1=1, the remaining 0 |
| |
bitwise OR operation, 1 is 1, otherwise 0 |
^ |
Bitwise XOR, same as 0, different 1 |
~ |
bitwise NON, ~0=1,~1=0 |
<< |
Left-shift operation, all bits shifted to the left |
>> |
Right shift operation, all bits shifted right |
Third, comparison operators
Comparison operators |
Specific description |
== |
|
! = |
Inequality operator |
<> |
Unequal operators, same! = |
< |
|
> |
|
<= |
|
>= |
|
Four, logical operators
logical operators |
Specific description |
and |
Logic and operations |
Or |
Logical OR operation |
Not |
Logical non-operation |
Five, string operators
Operator |
Specific description |
+ |
String connection |
* |
Repeating output string |
[] |
Get the position character by index, index starting from 0 |
[Start,end] |
Intercept part of a string, from start to End-1 |
Inch |
A member operator that returns true if the string contains the given character |
Not in |
Member operator, which returns true if the string does not contain the given character |
R or R |
Specifies the original string, which means that all strings are used directly as literal meanings, without escape characters, Special characters or characters that cannot be printed. The first quotation mark of the original string is preceded by the letter R or R |
the precedence of the operator (top-to-bottom represents the high and low of the operation priority)
Meta operator |
Specific description |
** |
|
~, +,- |
Here the +,-refers to the plus or minus |
*、/、%、// |
|
+,- |
Here the +,-refers to the addition and subtraction |
>>, << |
|
& |
|
^, | |
|
>, = =,! = |
|
%=,//= 、...... |
All assignment operators |
is, is not |
Identity operator |
In, not in |
Member operators |
Not, or, and |
logical operators |
Python Basic 5-operator