代码
import re
def password_is_ok(password: str) -> bool:
"""
1. 密码只能是字母数字组合
2. 密码必须包含大小写字母以及数字
"""
result = re.findall('^(?=.*\d+)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,16}$', password)
return True if result else False
if __name__ == '__main__':
s = '12345678xyzF aa123 aA123456 985211aaa admin admin66Z'
for password in s.split():
print(password, password_is_ok(password))