【发布时间】:2016-12-06 14:52:29
【问题描述】:
这是用于检查密码是否为 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)
【问题讨论】:
-
在您的一些方法调用之后,您缺少
()。
标签: python passwords alphanumeric isalpha