密码输入检测
#定义一个输入控制的函数
def input_password(input_str):
#字符串转换成列表
list_password = []
for char in input_str:
if char == '<':
list_password.pop()
else:
list_password.append(char)
#列表转换成字符串
password = ''.join(list_password)
return password
#定义一个检查密码长度的函数
def check_password_length(password):
if len(password) >= 8:
return True
else:
return False
if __name__ == '__main__':
input_str = input().strip()
password = input_password(input_str)
#检查密码格式
check_password_format = any(char.isupper() for char in password) and any(char.islower() for char in password)\
and any(char.isdigit() for char in password)
check_password_special = any(not char.isalnum() and not char.isspace() for char in password)
check_password_length = check_password_length(password)
check_password = False
if check_password_format and check_password_length and check_password_special:
check_password = True
print(f'{password},{check_password}')