我正在 python 上编写密码强度代码,我试图找出我的密码 ( p
) 是否包含一个数字,我已经找到了如何查看它是否包含大写和小写字母p.isupper()
or p.islower()
。我也把它们两个放在一起。我的朋友告诉我如何查看密码是否只包含数字,但我现在需要你的帮助。
running=True
while running:
p=raw_input("What is your Password? ")
if len(p) <6:
print "Your Password is too short"
if len(p) >12:
print "Your Password is too long"
if len(p) == 6 or 7 or 8 or 9 or 10 or 11 or 12:
print "Password Length OK"
running=False
print "Loop Broken" #this will be deleted, only for my help now
if p.isupper():
print "Your Password is weak as it only contains capital letters"
if p.islower():
print "Your Password is weak as it only contains lower case letters"
if p.isupper and p.islower:
print "Your Password is of medium strength, try adding some numbers"
try:
int(p)
print "Your Password is weak as it only contains numbers"
except (ValueError, TypeError):
pass
我现在需要的只是密码,如果密码包含小写或大写字母和数字。