gpt4 book ai didi

python - 检查字符串是否只包含一些值,而不包含其他值

转载 作者:太空宇宙 更新时间:2023-11-04 08:08:39 26 4
gpt4 key购买 nike

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 ==

这是我想问密码是否只包含数字的地方,但我不知道该怎么做,我已经尝试过使用 ands 和 ors,但失败得很惨。

最佳答案

使用isdigit()

>>> "abcd123".isdigit()
False

>>> "123".isdigit()
True

关于python - 检查字符串是否只包含一些值,而不包含其他值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27058723/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com