这是用于检查密码是否为 9 个字符长、字母数字且包含至少 1 个数字的函数的一部分。理想情况下,我应该能够使用第一个 if 语句,但奇怪的是,它没有运行。我无法弄清楚为什么 test1.isalpha 在 if 语句中运行为“真”但打印为“假”。
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)