蝴蝶不菲
(a>0 or b>0) and not (a>0 and b>0)
或者
(a>0 or b>0) and a*b<=0
示例代码:
def ab(a,b):
if (a>0 or b>0) and a*b<=0:
return True
else:
return False
for a,b in [(1.5,-1.0),(2,0),(-3,0),(-2.1,-3),(2,2)]:
print "a=%.1f,b=%.1f:"%(a,b),ab(a,b)