对于以下示例:
def fuctionName(int, bool):
if int in range(...):
if bool == True:
return False
else:
return True
Run Code Online (Sandbox Code Playgroud)
有没有办法跳过第二个if语句?只是告诉计算机返回布尔值的反面bool?
if myval == 0:
nyval=1
if myval == 1:
nyval=0
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法在python中进行切换,比如nyvalue = not myval?