给定以下代码(不起作用):
while True:
# Snip: print out current state
while True:
ok = get_input("Is this ok? (y/n)")
if ok.lower() == "y": break 2 # This doesn't work :(
if ok.lower() == "n": break
# Do more processing with menus and stuff
有没有办法让这个工作?或者我必须做一次检查来打破输入循环,然后再做一次更有限的检查,如果用户满意,在外循环中检查以一起打破所有循环?