
上QQ阅读APP看书,第一时间看更新
4.8 算术运算符和位运算符
4.8.1 算术运算符
Python提供了丰富的算术运算符,用于进行包括四则运算的各种算术运算。表4-12以优先级顺序列出了Python中的算术运算符。假设该表中的n为整型变量,取值为8。
表4-12 算术运算符

4.8.2 位运算符
位运算符用于按二进制位进行逻辑运算,操作数必须为整数。Python中的位运算符如表4-13所示。
表4-13 位运算符

【例4.20】 位运算符示例(op_bit.py)。

程序运行结果如下。
