在python中,说是否有区别:
if text == 'sometext':
print(text)
if text == 'nottext':
print("notanytext")
Run Code Online (Sandbox Code Playgroud)
和
if text == 'sometext':
print(text)
elif text == 'nottext':
print("notanytext")
Run Code Online (Sandbox Code Playgroud)
只是想知道多个ifs是否会导致任何不必要的问题,以及是否更好的做法使用elifs.