下面是我的项目软件中的一段代码:def fun_1(self, i):
print("")
print("Welcome to Option 1: View Passwords")
while True:
print("")
which_o1 = input("1: Input a New Account details \n2: Exit \nPlease Input the option number: ")
if which_o1 == str(1):
with open(str(i)+'.txt', 'a+') as file:
while True:
print("")
web_n = input("Please Input Website name: ")
print("")
e_u = input("Please input email/username: ")
print("")
pass_w = input("Please input password: ")
while True:
print("")
sure = input("Website- " +web_n+"\nEmail/Username- "+e_u+"\nPassword- "+pass_w+"\nAre You sure about these details? Yes/No: ")
if (sure.lower()[0]) != 'y' and (sure.lower()[0]) != 'n':
print("")
print("Please input a valid response Yes/No!")
continue
elif (sure.lower()[0]) == 'y' and (sure.lower()[0]) != 'n':
list_log = [web_n, e_u, pass_w]
file.write(str(list_log) + '\n')
break
break
continue
elif (sure.lower()[0]) == 'n' and (sure.lower()[0]) != 'y':
break
continue
elif which_o1 == str(2):
return (i)
else:
print("")
print("Please Enter a Valid Response!")
continue
所以你可以看到它有3个while真循环。在中断和循环循环循环时出现问题。如果你在中间elif的“pass_w”下看到了最新的While True,它的意思是elif (sure.lower()[0]) == 'y' and (sure.lower()[0]) != 'n':,在其中我有2个break和1个continue,因为我想做的是,当elif执行它时,只中断middle 3rd While True,2nd While True,continue意味着在代码开始时循环第一个While True,但它只是在代码中间继续循环第三个,而不是破坏它。在
有没有办法让它成为可能?在