我目前正在使用正则表达式来分别检查他们,所以我更喜欢使用re的答案。在
一个我用来分别找到它们的例子:
if re.search(r'[A-Z]', userpass):
score += 5
但是,我想检查变量是否包含所有参数(大写/小写、符号和数字),因此使用搜索每次都会返回true,因为它只检查是否有一个数字,但我想检查是否有一个数字,大小写和符号。我想检查的符号是:!$%^&;*()-\
另外,对clarfy来说,我对python相当陌生,所以除了基本的东西之外,几乎所有的东西对我来说都是新的,所以我使用regex,因为我发现它非常简单
对于非regex解决方案,您可以使用以下内容:
不带正则表达式:
我认为它可能更适合使用正则表达式。相反,我只使用
all()
和any()
:相关问题 更多 >
编程相关推荐