小编whi*_*ite的帖子

确定是否有两个相同的字符彼此相邻

我被要求创建一个程序来识别密码是否有效。我正在努力解决的一个部分是确定是否有两个相同的字符彼此相邻。帮助将不胜感激,这是迄今为止的程序:

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.")
Run Code Online (Sandbox Code Playgroud)

python regex python-3.x

5
推荐指数
1
解决办法
2808
查看次数

标签 统计

python ×1

python-3.x ×1

regex ×1