我正在编写一个具有多个属性的密码分析器,其中之一是用户的密码不得包含特殊字符(@#$%^& *),除了!(感叹号)和_(下划线)。我正在使用该.isalnum()方法来实现此目的,但我无法找到一种方法来实现它,因此它不会返回 True !或_与任何其他特殊字符一起使用(例如:Python$返回 False 但Python_返回 True)。这是我的代码:
password = input('Enter a password: ')
if not password.isalnum():
if '_' in password or '!' in password:
pass
else:
print('Your password must not include any special characters or symbols!')
暮色呼如
跃然一笑
月关宝盒
幕布斯7119047
相关分类