检查字符串是否仅包含某些值,而不包含其他值

Raz*_*zor 1 python

print("Hello, welcome to password strength. Test how strong your password is todai!")
password = input("Well enter a password why don't you... ")
print("So your password is", password)
print("Well ok, let's see what i can understand from this...")

if len(password) < 6:   
    print("Your password is too short")    
else:    
    print("Your password is of a good length")    

if password == password.upper():    
    print("Your password has too many uppercase letters")
else:    
    print("Your password has 0 or a couple upper case letters, please consider making your password remember-able.")

if password == password.lower():    
    print("Your password needs a upper case letter case letters")
else:    
    print("Your password has a suitable amount of lowercase vs upper case letters")

if password == 
Run Code Online (Sandbox Code Playgroud)

这是我想问的密码是否仅包含数字,但我不知道如何做到这一点,我已经尝试使用ands和ors,但失败了.

Jin*_*Jin 5

使用 isdigit()

>>> "abcd123".isdigit()
False

>>> "123".isdigit()
True
Run Code Online (Sandbox Code Playgroud)