相关疑难解决方法(0)

多个if和elif之间的区别?

在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.

python if-statement

62
推荐指数
5
解决办法
6万
查看次数

标签 统计

if-statement ×1

python ×1