所以我有一个 if 语句,当满足 if 语句的条件时,我想阻止下面的行运行。
import turtle
if password not in ("password"):
print("access denied.")
turtle.bgcolor("red")
turtle.write("access denied.", font=style)
turtle.done()
#i want to prevent all lines from the rest of the script following this line from running
也许尝试将所有代码放入 while 循环中,如果满足 if 条件,则在 if 语句的末尾添加 break 以便:
import turtle
while True:
if password not in ("password"):
print("access denied.")
turtle.bgcolor("red")
turtle.write("access denied.", font=style)
turtle.done()
break
else:
'whatever next condition is'
如果没有看到更多可测试的代码,很难说清楚,但我认为这对你有用
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句