【发布时间】:2018-03-31 19:53:39
【问题描述】:
有人要求我创建一个程序来识别密码是否有效。我正在努力解决的一个问题是确定是否有两个相同的字符彼此相邻。我们将不胜感激,这是迄今为止的程序:
import re
pswrd = input("Enter Desired Password:")
if len(pswrd) < 6:
print("Password must have more than 6 characters.")
if len(pswrd) > 15:
print("Password must have no more than 15 characters.")
if re.search("[$#@]",pswrd):
print("Password must have no special characters.")
if not re.search("[0-9]",pswrd):
print("Password must contain a number.")
if not re.search("[a-z]",pswrd):
print("Password must contain a lower case letter.")
if not re.search("[A-Z]",pswrd):
print("Password must contain an upper case letter.")
【问题讨论】:
-
最小密码长度的测试和响应不一致。 (“小于6”不是“大于6”的反义词)
标签: python regex python-3.x