2024-06-08 16:21:19 发布
网友
也许这是一个愚蠢的问题,我犯了一个愚蠢的错误,但我不能让这个控制流工作。 以下是我的简化代码:
for x in range(1,10): print(x) if x==2: print("working") break else: print("stop")
以下是shell的结果:
1 2 working
有人能帮我吗?你知道吗
您的程序正在按预期和指定的方式工作。从the official Python 3 documentation:
A break statement executed in the first suite terminates the loop without executing the else clause’s suite.
您的程序正在按预期和指定的方式工作。从the official Python 3 documentation:
相关问题 更多 >
编程相关推荐