我有以下要求来验证密码,需要满足以下条件:
- 至少一个数字
- 至少一个大写字母
- 至少一个小写字母
- 至少一个特殊字符[$@#]
#!/usr/sfw/bin/python
import re
password = raw_input("Enter string to test: ")
if re.match(r'[A-Za-z0-9@#$]{6,12}', password):
print "match"
else:
print "Not Match"
正在使用:
localhost@user1$ ./pass.py
Enter string to test: abcdabcd
match
它正在评估错误的输出。有人能建议我是否应该使用re.search
吗?