040 Python语法之operator模块

操作符工具类

import operator

a=10
b=20
print(operator.lt(a,b)) #lt  等价 <
print(operator.le(a,b)) #le  等价于<=
print(operator.ge(a,b)) # ge  等价 >=
print(operator.gt(a,b))#  gt  等价 >
print(operator.eq(a,b))# eq   等价    ==
print(operator.ne(a,b))#   ne  等价   !=

你可能感兴趣的:(040 Python语法之operator模块)