Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python总是说它非常强大,当它';超过8个字符_Python_Debugging - Fatal编程技术网

Python总是说它非常强大,当它';超过8个字符

Python总是说它非常强大,当它';超过8个字符,python,debugging,Python,Debugging,如果密码强度指示器大于或等于任何类型的8个字符,它总是告诉我“非常强” 以前我的代码总是有语法错误,但现在它甚至没有告诉我出了什么问题,我在很多其他地方都找过,但我找不到它。 以下是代码: print('This program measures the strength of your password. It is safe.') # Input password. password = input('Please enter your trial password:') # Check

如果密码强度指示器大于或等于任何类型的8个字符,它总是告诉我“非常强”

以前我的代码总是有语法错误,但现在它甚至没有告诉我出了什么问题,我在很多其他地方都找过,但我找不到它。 以下是代码:

print('This program measures the strength of your password. It is safe.')
# Input password.

password = input('Please enter your trial password:')

# Check password.

if len(password) >=8 and password.isalnum():
    print('You have a very strong password.')
elif len(password) >=8 and password.isalpha():
    print('You have a strong password.')

所以它总是说,只要密码大于或等于8个字符,密码就非常强,但我只想让它说“非常强”,只要密码有数字、字母,最好还有特殊字符。我正在尝试将“非常强”标识为大于或等于8个字符的密码,并且包含字母和至少一个数字。

阅读“isalnum”的文档?
isalnum
是正确的,如果它包含字母或数字字符,则不必同时包含这两个字符。(此外,这将是显示输入和数字的一个好问题。)[意外]输出,因为这也会很快揭示“问题”。)使用正则表达式,我认为没有任何内置函数可以满足您的需要。搜索[regex]密码强度,您会找到一些解决方案。