def pdsz(cd): |
nnnn = False |
for c in cd: |
if c.isnumeric(): |
nnnn = True |
break |
return nnnn |
def pdzm(cd): |
nnnn = False |
for c in cd: |
if c.isupper(): |
nnnn = True |
break |
return nnnn |
def pdhh(cd): |
nnnn = False |
for c in cd: |
if c.islower(): |
nnnn = True |
break |
return nnnn |
def main(): |
""" |
主函数 |
""" |
cscs = 5 |
while cscs > 0 : |
password = input ( '请输入密码:' ) |
#密码强度判断 |
stregth_level = 0 |
jch = 0 |
# |
if len (password) > = 8 : |
stregth_level + = 1 |
else : |
print ( '密码长度必须大于8位' ) |
if pdsz(password): |
stregth_level + = 1 |
jch = '弱' |
else : |
print ( '密码必须包含数字!' ) |
if pdzm(password): |
stregth_level + = 1 |
jch = '中' |
else : |
print ( '密码必须包含大写字母!' ) |
if pdhh(password): |
stregth_level + = 1 |
jch = '较强' |
else : |
print ( '密码必须包含小写字母!' ) |
# f = open('111', 'a') |
# f.write(password) |
# f.close() |
if stregth_level = = 4 : |
jch = '强' |
print ( '密码强度合格' ) |
f = open ( '111' , 'a' ) |
f.write( '密码:{}, 强度:{}\n' . format (password,jch)) |
f.close() |
break |
else : |
print ( '密码强度不合格' ) |
cscs - = 1 |
print () |
if cscs < = 0 : |
print ( '尝试次数过多!' ) |
if __name__ = = '__main__' : |
main() |
初级程序员
by: scp-173 发表于:2020-03-09 11:29:03 顶(0) | 踩(0) 回复
为啥不能运行捏
回复评论