0
有沒有一種方法可以檢查一個while循環條件在Python循環中是否仍然是真的?類似這樣的:評估while循環在某一點?
i = 0
while i < 2:
i = 2
evalcond
print("This executes because the condition is still true at this point")
這可能嗎?
有沒有一種方法可以檢查一個while循環條件在Python循環中是否仍然是真的?類似這樣的:評估while循環在某一點?
i = 0
while i < 2:
i = 2
evalcond
print("This executes because the condition is still true at this point")
這可能嗎?
也許這樣的事情?
i = 0
while i < 2:
i = 2
if i >= 2:
break
print("This executes because the condition is still true at this point")
如果你想避免使用break
你也可以做到這一點
i = 0
while i < 2:
i = 2
if i < 2:
print("This executes because the condition is still true at this point")
看起來像你想有一個',而1:'和'如果... break'結構。 – TigerhawkT3