+:加 -:减 *:乘 /:除(python2获取的是整数,python3中获取有小数) //:整除。地板除;
print(5//2) 2**:幂(次方)
print(5**2) 25%:取模(余数)
print(5%2) 1>:大于 <:小于 ==:等于 !=:不等于 >=:大于等于 <=:小于等于
=:赋值 +=:自加。a+=2–》a=a+2 -=:自减。xx=xx-xx *=:自乘。xx=xx*xx /=:自除。xx=xx/xx //=:xx=xx//xx **=:xx=xx**xx %=:xx=xx%xx
优先级:()–>not–>and–>or
and:与
都为真时取and后边的值 都为假时取and前面的值 一真一假时取假的
print(3 and 4) 4 print(0 and 4) 0 print(0 and False) 0or:或
都为真时取or前边的值 都为假时取or后面的值 一真一假取真的
print(0 or False or 2 or 3 or 76) 2not:非
print(not True) Falsein:存在 not in:不存在
s = "woshenshendenaohaili" print('sh' in s) True