def opstr_to_op(opstr):
if opstr == "<=":
return operator.le
elif opstr == ">=":
return operator.ge
elif opstr == "<":
return operator.lt
elif opstr == ">":
return operator.gt
elif opstr == "=":
return operator.eq
elif opstr == "-":
return operator.sub
elif opstr == "+":
return operator.add
elif opstr == "/":
return operator.div
elif opstr == "*":
return operator.mul
elif opstr == "and":
return operator.and_
elif opstr == "or":
return operator.or_
elif opstr == "not":
return operator.not_
else:
raise Exception("Opstr not supported: {}".format(opstr))
评论列表
文章目录