這是用於檢查密碼長度爲9個字符,字母數字且至少包含1個數字的函數的一部分。理想情況下,我應該能夠使用第一條if語句,但很奇怪,它不會運行。我無法弄清楚爲什麼test1.isalpha在if語句中作爲'True'運行,但打印爲'False'。.isalpha打印爲False,但選中時爲True
test1 = 'abcd12345'
if len(test1) == 9 and test1.isalnum and not(test1.isalpha)
print('This should work.')
if len(test1) == 9 and test1.isalnum:
if (test1.isalpha):
print('test1 is', test1.isalpha())
>>>('test1 is', False)
在您的一些方法調用之後,您缺少'()'。 – khelwood