因为 你设置的是passwords != ent 所以 passwords = ent是不可能被执行的
给你改一下代码:
感谢矫正{:5_109:} 现在这个是改好的吗? AllTheBestCheer 发表于 2020-6-11 17:09
感谢矫正
设个最佳吧{:5_109:} 解决这个问题的话,主要是因为你的
if passwords == ent:
print ('密码正确!进入程序。。。。。')
这条语句是在while循环里的,也就是说你在输入不等于密码的循环体里,非要假设输入等于密码,while也懵了啊
直接把这条语句删去,把print ('密码正确!进入程序。。。。。')放在最后且while循环体之外就好了
如下:
passwords = 'FishC.com'
ent = input('请输入密码 (你有三次机会输入):')
times = 3
while passwords != ent:
if times == 1:
print ('超出输入次数 结束')
break
else:
if ('*' in ent):
times -= 1
ent = input ('密码输入错误!(密码含有*符号) 你还有%d'%(times)+'机会')
else:
times -= 1
ent = input ('密码输入错误!你还有%d'%(times)+'机会')
print ('密码正确!进入程序。。。。。')
其余小问题再调整下就🆗了 云鹿 发表于 2020-6-11 19:19
解决这个问题的话,主要是因为你的
if passwords == ent:
print ('密码正确!进入程序。。。。。 ...
这样不行的噢~ 如果次数用完,也会打印密码正确!进入程序哦,但是你的代码在加个else 就对了~
passwords = 'FishC.com'
ent = input('请输入密码 (你有三次机会输入):')
times = 3
while passwords != ent:
if times == 1:
print ('超出输入次数 结束')
break
else:
if ('*' in ent):
times -= 1
ent = input ('密码输入错误!(密码含有*符号) 你还有%d'%(times)+'机会')
else:
times -= 1
ent = input ('密码输入错误!你还有%d'%(times)+'机会')
else:
print ('密码正确!进入程序。。。。。')
Twilight6 发表于 2020-6-11 19:35
这样不行的噢~ 如果次数用完,也会打印密码正确!进入程序哦,但是你的代码在加个else 就对了~
好滴!谢谢! AllTheBestCheer 发表于 2020-6-11 17:09
感谢矫正
……估计程序用不到矫正 本帖最后由 Mike_python小 于 2020-6-14 08:08 编辑
passwords = 'FishC.com'
ent = input('请输入密码 (你有三次机会输入):')
times = 3
while True:
if times == 1:
print ('超出输入次数 结束')
break
if passwords == ent:
print ('密码正确!进入程序。。。。。')
break
else:
if ('*' in ent):
times -= 1
ent = input ('密码输入错误!(密码含有*符号) 你还有%d'%(times)+'机会')
else:
times -= 1
ent = input ('密码输入错误!你还有%d'%(times)+'机会')
求最佳{:10_254:}
页:
1
[2]