-1
def IsValidLogin(login_name):
lognum = 0
login = 0
if len(login_name) >= 8:
lognum == True
elif len(login_name) < 8:
lognum == False
for chr in login_name:
if chr.isalnum() == True:
login == True
else:
login == False
if (login == True) and (lognum == True):
IsValidLogin == True
else:
IsValidLogin == False
if IsValidLogin == True:
print('Login Accepted')
else:
print('Login Failed')
return lognum, login
login_name = input('Please enter your Login: ')
lognum, login = IsValidLogin(login_name)
def IsValidPassword(password):
pass_char = ['!','@','#','$','%','^','&','*','(',')','_','+']
pass_len = 0
pass_num = 0
spec_char = 0
for chr in password:
if len(password) >= 8:
pass_len == True
elif len(password) < 8:
pass_len == False
for chr in password:
if chr.isdigit() == True:
pass_num == True
elif chr.isdigit() == False:
pass_num == False
for chr in password:
if password == pass_char:
spec_char == True
elif password != pass_char:
spec_char == False
if (pass_len == True) and (spec_char == True):
IsValidPassword == True
else:
IsValidPassword == False
if IsValidPassword == True:
print('Password Accepted')
else:
print('Password Failed')
return pass_len, pass_num, spec_char
password = input('Please enter your password: ')
pass_len, pass_num, spec_char = IsValidPassword(password)
登錄名至少需要8個字符並且只能包含字母和數字。驗證登錄名和密碼
密碼長度必須至少爲8個字符,至少包含一個數字和一個特殊字符。
程序運行,但都返回false。
想知道我做錯了什麼。請記住我是Python新手。