基础入门:python中的位运算符
python中运算符的优先级
python中运算符的知识点总结
源代码:
# 2962909897@qq.com
# 开发时间:2022/10/3 16:54
print(4 & 8) # 按位与&,同为1时结果为1
print(4 | 8) # 按位或|,同为0时结果为0
print(4 << 1) # 向左移动一位(移动1个位置) 相当于乘于2
print(4 << 2) # 向左移动二位(移动2个位置)
print(4 >> 1) # 向右移动一位(移动1个位置) 相当于除于2
print(4 >> 2) # 向右移动二位(移动2个位置)
源代码运行情况: