while True:
try:
username = input("Username: ")
if len(username) >= 6 and len(username) <= 20 and username.isalpha():
break
else:
print("用户名长度6-20 and 必须字母开头")
except Exception:
print("用户名长度6-20 and 必须字母开头")
while True:
try:
password = input("Password: ")
if len(password) >= 6 and not password.isdigit() and not password.isspace():
break
else:
print("密码长度至少6位 不能纯数字 有空格")
except Exception:
print("密码长度至少6位 不能纯数字 有空格")
print(f'设置成功!用户:{username},密码:{password}')