1.and or not : 与 或 非
2.is , is not 同一性判断,判断是否为同一对象
3.| ^ & 按位或 按位异或 按位与
3.<< >> 移位
4.~ 按位翻转
5.+ - * / // % 加 减 乘 浮点除 整数除 取余
6.** 幂运算
1.比较运算符可连用
>>> a =4 >>> 3<a<10 True #比较运算符可连用
2.位操作
>>> a = 0b11001 >>> b = 0b01000 >>> c = a|b >>> bin(c) '0b11001' >>> bin(c&b) '0b1000' >>> bin(c^b) '0b10001'
3.加法操作
①数字相加 3+2 ==> 5
②字符串拼接 "3" + "2" ==> "32"
③列表、元组等合并 [10,20,30] + [5,10,100] ==> [10,20,30,5,10,100]
4.乘法操作
①数字相乘 3*2 ==> 6
②字符串复制 "sxt" *3 ==> "sxtsxtsxt"
③列表、元组等复制 [10,20,30] * 3 ==> [10,20,30,10,20,30,10,20,30]
复合赋值运算符
注:python 不支持 自增(++) 自减(--)操作
运算符优先级问题
如下优先级,从高到低
实际中用()来组织
1.乘除优先与加减
2.位运算和算术运算> 比较运算>赋值运算