如何显示密码测试器输入的所有错误
How to display everything wrong with input for password tester
我的程序工作得很好,但不会 return 把所有密码都弄错了,它只会 return 一个问题。
示例:
密码是 ASD123(问题是少于 10 个字符,并且没有符号)。程序只有returns"The password is less than 10 characters"
passwordisokk = True
def passwordisOK():
while True:
passwordisokk = input("Please enter a password so we can validate:")
if len(passwordisokk) < 10:
print(" Your password should be 10 characters,please enter more characters")
passwordisokk = False
print(passwordisokk)
elif re.search("[0-9]",passwordisokk) is None:
print("Your password needs a number,please enter one")
passwordisokk = False
print(passwordisokk)
elif re.search("[A-Z]",passwordisokk) is None:
print(" Your password needs a capital letter,please enter one")
passwordisokk = False
print(passwordisokk)
elif re.search("[$,#,%,&,*]",passwordisokk) is None:
print(" You password needs one of these symbols:$,#,%,&,*. Please enter one")
passwordisokk = False
print(passwordisokk)
elif re.search("[ ]",passwordisokk):
passwordisokk = False
print("No spaces when entering your password please")
print(passwordisokk)
else:
passwordisokk = True
print(passwordisokk)
break
passwordisOK()
只需将 elif
和 else
更改为 if
语句即可。
import re
passwordisokk = True
def checkPasswordisOK():
while True:
password = input("Please enter a password so we can validate:")
if len(password) < 10:
print(" Your password should be 10 characters,please enter more characters")
passwordisokk = False
print(passwordisokk)
if re.search("[0-9]",password) is None:
print("Your password needs a number,please enter one")
passwordisokk = False
print(passwordisokk)
if re.search("[A-Z]",password) is None:
print(" Your password needs a capital letter,please enter one")
passwordisokk = False
print(passwordisokk)
if re.search("[$,#,%,&,*]",password) is None:
print(" You password needs one of these symbols:$,#,%,&,*. Please enter one")
passwordisokk = False
print(passwordisokk)
if re.search("[ ]",password):
passwordisokk = False
print("No spaces when entering your password please")
print(passwordisokk)
if not passwordisokk:
passwordisokk = True
print(passwordisokk)
break
checkPasswordisOK()
我的程序工作得很好,但不会 return 把所有密码都弄错了,它只会 return 一个问题。
示例: 密码是 ASD123(问题是少于 10 个字符,并且没有符号)。程序只有returns"The password is less than 10 characters"
passwordisokk = True
def passwordisOK():
while True:
passwordisokk = input("Please enter a password so we can validate:")
if len(passwordisokk) < 10:
print(" Your password should be 10 characters,please enter more characters")
passwordisokk = False
print(passwordisokk)
elif re.search("[0-9]",passwordisokk) is None:
print("Your password needs a number,please enter one")
passwordisokk = False
print(passwordisokk)
elif re.search("[A-Z]",passwordisokk) is None:
print(" Your password needs a capital letter,please enter one")
passwordisokk = False
print(passwordisokk)
elif re.search("[$,#,%,&,*]",passwordisokk) is None:
print(" You password needs one of these symbols:$,#,%,&,*. Please enter one")
passwordisokk = False
print(passwordisokk)
elif re.search("[ ]",passwordisokk):
passwordisokk = False
print("No spaces when entering your password please")
print(passwordisokk)
else:
passwordisokk = True
print(passwordisokk)
break
passwordisOK()
只需将 elif
和 else
更改为 if
语句即可。
import re
passwordisokk = True
def checkPasswordisOK():
while True:
password = input("Please enter a password so we can validate:")
if len(password) < 10:
print(" Your password should be 10 characters,please enter more characters")
passwordisokk = False
print(passwordisokk)
if re.search("[0-9]",password) is None:
print("Your password needs a number,please enter one")
passwordisokk = False
print(passwordisokk)
if re.search("[A-Z]",password) is None:
print(" Your password needs a capital letter,please enter one")
passwordisokk = False
print(passwordisokk)
if re.search("[$,#,%,&,*]",password) is None:
print(" You password needs one of these symbols:$,#,%,&,*. Please enter one")
passwordisokk = False
print(passwordisokk)
if re.search("[ ]",password):
passwordisokk = False
print("No spaces when entering your password please")
print(passwordisokk)
if not passwordisokk:
passwordisokk = True
print(passwordisokk)
break
checkPasswordisOK()