python 循环嵌套 continue_Python多个嵌套while True continue/end循环

下面是我的项目软件中的一段代码: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,但它只是在代码中间继续循环第三个,而不是破坏它。在

有没有办法让它成为可能?在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值