Python The operators in are mainly divided into arithmetic operators 、 Compare ( Relationship ) Operator 、 Assignment operator 、 Logical operators 、 An operator 、 The membership operator and the identity operator share 7 Categories: , Operators are also determined by priority .
>>> 5 + 4
9
>>> 4.3 - 2
2.3
>>> 3 * 7
21
>>> 2 / 4
0.5
>>> 2 // 4
0
>>> 17 % 3
2
>>> 2 ** 5
32
Python Comparison ( Relationship ) Operator of 6 individual
>>> a =1
>>> b =2
>>> print(a == b)
False
>>> print(a != b)
True
Python The assignment operators of are 8 individual
>>> a =2
>>> b =3
>>> a+=b
>>> print(a)
5
>>> a-=b
>>> print(a)
2
Python The logical operators of are 3 individual
>>> a =True
>>> b =False
>>> print(a and b)
False
>>> print(a or b)
True
>>> print(not(a and b))
True
Python Bitwise operators of 6 individual
>>> a=55 #a=0011 0111
>>> b=11 #b=0000 1011
>>> print(a&b)
3
>>> print(a|b)
63
Python The member operators of are 2 individual
>>> a=1
>>> b=20
>>> l = [1, 2, 3, 4, 5]
>>> print(a in l)
True
>>> print(b not in l)
True
Python The identity operators of are 2 individual
>>> a=123
>>> b=123
>>> c=456
>>> print(a is b)
True
>>> print(a is not c)
True