运算符
+
-
*
/ (python2中 5/2=2;;;python3中 5/2=2.5)
//(整除-地板除)
**幂(次方) 【print(3**2) 输出9】
% 模(取余)
print(5 % 2)
>
<
== (等于)
!= (不等于)
>=
<=
= 赋值
+= 自加
# 例子a = 10
a += 1 (相当于 a = a +1 )
print(a)
-= (自减)
*= (自乘)
/=
//=
**=
%=
and (与/和)
or (或)
not (非)
print(3 and 4) 取 4
print(0 and 4) 取 0
print(0 and False) 取 0
and 都为真的时候取后值
and 都为假的时候取前值
and 一真一假取假的
print(3 and 5 and 9 and 0 and False) 取 0
print(5 and False and 9 and 0) 取 False
print(1 and 2 and 5 and 9 and 6) 取 6
or 都为真的时候取前值
or 都为假的时候取后值
or 一真一假取真的
print(1 or 0) 取 1
print(1 or 2) 取 1
print(0 or False) 取 False
print(not False) #相反
() > not > and > or 执行先后顺序
print(9 and 1 or not False and 8 or 0 and 7 and False)
9 and 1 or not False and 8 or 0 and 7 and False
9 and 1 or True and 8 or 0 and 7 and False
1 or True and 8 or 0 and 7 and False
1 or 8 or 0 and 7 and False
1 or 8 or 0 and False
1 or 8 or 0
1
in 存在
not in 不存在
s = "xiaogege"
if "lt" not in s:
print(True)
else:
print(False)