我有这个功能
def postData():
data = doPOst()
if data.result == "success":
return data
if data.result == "fail":
return false
然后我基于回归我必须做类似
的事情if ret is None:
pass # 1
if ret is False:
pass # 2
else:
normal
我想知道将无和无效混合
答案 0 :(得分:3)
如果您明确检查None
和False
,则不会,它们将无法合并。
if ret is None: # entered only on None
pass
elif ret == False: # entered only on False or 0
pass
else:
pass
如果您刚检查了真值/假值,它们会合并:
if ret:
pass
else: # entered on None or False
pass