
|
运算符优先级 |
|
**(求幂) |
|
~(按位取反) +(正号) -(负号) |
|
* / % // |
|
+(加) -(减) |
|
>> << |
|
&(按位与) |
|
^(按位异或) |(按位或) |
|
<= < > >= |
|
== != |
|
= %= += -= //= |
|
is is not |
|
in not in |
|
not or and |
算术运算表达式
1 num1 = 5
2 num2 = 3
3 print(num1 + num2)
4 print(num1 - num2)
5 print(num1 * num2)
6 print(num1 / num2)
7 print(num1 % num2)
8 print(num1 ** num2)
9 print(num1 // num2)

位运算
print(5 & 7)
‘‘‘
101
&
111
--------
101
‘‘‘
print(5 | 7)
print(2 << 2)
‘‘‘
000000010 (左移2位)
---------------
000001000
‘‘‘
print(13 >> 2)
‘‘‘
0000001101 (右移2位)
---------------------
0000000011
‘‘‘

原文:https://www.cnblogs.com/jicongcong/p/12595587.html