python基础语法2---运算符

Python算术运算符

  1. +
  2. -
  3. *
  4. /
  5. **
  6. //
  7. %

Python比较运算符

  1. ==
  2. !=
  3. <
  4. >
  5. <=
  6. >=

Python赋值运算符

  1. =
  2. +=
  3. -=
  4. *=
  5. /=
  6. %=
  7. //=

Python位运算符

用到的时候再了解……

Python逻辑运算符

  1. and
  2. or
  3. not

Python成员运算符

  1. in
  2. not in

Python身份运算符

  1. is
  2. is not
a = 20
b = 30
if ( a is b ):
   print ("3 - a 和 b 有相同的标识")
else:
   print ("3 - a 和 b 没有相同的标识")

if ( a is not b ):
   print ("4 - a 和 b 没有相同的标识")
else:
   print ("4 - a 和 b 有相同的标识")

猜你喜欢

转载自blog.csdn.net/weixin_36926779/article/details/80975502
今日推荐