|  | 
 
| 
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  复制代码password="FishC.com"
n=3
temp=input("请输入密码:")
while (temp != password and n>0):
    if ('*' in temp) and n>0:
        print("密码中不能含有"*"号!您还有%d次机会!请输入密码:" %(n),end='')
        temp=input()
    else:
        n=n-1
        
        print("密码输入错误!您还有%d次机会!请输入密码:" %(n),end='')
        tmep=input()
 这一段程序为什么在运行过一次n=n-1之后,哪怕输入带*也还是会执行n=n-1操作,不会保留原n
 
 
 
 
 
你的这句代码如果要这样写要转义:
 复制代码 print("密码中不能含有\"*\"号!您还有%d次机会!请输入密码:" %(n),end='')
或者单双引号配合:
 
 复制代码 print("密码中不能含有'*'号!您还有%d次机会!请输入密码:" %(n),end='')
 复制代码# _*_ coding:utf8 _*_
password = "FishC.com"
n = 3
temp = input("请输入密码:")
while (temp != password and n > 0):
    if ('*' in temp) and n > 0:
        print("密码中不能含有" * "号!您还有%d次机会!请输入密码:" % (n), end='')
        temp = input()
    else:
        n = n - 1
        print("密码输入错误!您还有%d次机会!请输入密码:" % (n), end='')
        temp = input()
还有就是 temp 打错了
 
 | 
 |