我在我的代碼中的問題,我不知道如何解決 我甚至試圖把5個縮進在同一行但它沒有幫助 如果我錯了這裏有人可以重寫我的代碼,所以它會起作用嗎?我已經坐了大約40米,仍然無法找出問題,謝謝!IndentationError:預計在縮進塊的縮進塊
def grade_len(password):
if(len(password) <= 4):
return 0
if(5 <= len(password) <= 7):
return 5
if(len(password) > 7):
return 10
def grade_used(password):
if(password[0:9] == 'password' or 'love' in password or 'qwerty' in password or 'abc' in password):
return 0
else:
return 10
def grade_vari(password):
if(re.search('[a-z]',password) == False):
return 0
if(password.isalpha()):
return 3
if(password.lower == password.lower and password.isalpha() == False):
return 5
if(re.search('[a-z]',password) and re.search('[A-Z]',password) and re.search('[0-9]',password)):
return 7
if(re.search('[0-9]',password) and re.search('[a-z]',password) and re.search('[A-Z]',password) and re.match("[~\[email protected]#\$%\^&\*\(\)_\+{}\":;'\[\]]", password)):
return 10
def main():
password = raw_input ("enter password:")
test1 = grade_len(password)
test2 = grade_used(password)
test3 = grade_vari(password)
test_num = 3
test_average = (test1+test2+test3)/3
if(test_average<4):
print("Weak")
if(4<=test_average<=6):
print("Medium")
if(7<=test_average<=8):
print("Strong")
if(9<=test_average<=10):
print("Very strong")
main()
你是否在你的文件中導入了're'? –
您的代碼適用於我 – alDiablo
您應該爲一個級別的縮進使用4個空格。一致 - 每個縮進級別總是4個空格。 可能出現此錯誤,因爲在一個地方,您有一個空間可以更少或更多。看看你的代碼中沒有混合製表符和空格(一個好的IDE應該處理這個)。 – bodolsog