import time scale = 10 print("----------账号注册----------") user_name = input("请输入用户名(以“_”开头,3-30个字符):") password = input("请输入密码(由下划线、数字和字母共同组成,8-16个字符):") if user_name[0] != '_': print("用户名请使用下划线开头") elif len(user_name)>30 or len(user_name) <3: print("账户长度在3-30个字符之间") elif password.find('_') == -1: print("密码由下划线、数字和字母组成") elif len(password)>16 or len(password)<8: print("密码的长度为8-16个字符") else : password1 = password.replace('_','1') if password1.isalnum(): print("----------注册开始----------") for i in range(0, scale + 1): c = i * 10 a = '**' * i b = '..' * (scale - i) if c == 60: time.sleep(2) print("{:^3.0f}%[{}->{}]".format(c, a, b)) else: print("{:^3.0f}%[{}->{}]".format(c, a, b)) time.sleep(0.5) print("----------注册结束----------") print("账号:{}\n密码:{}".format(user_name, password)) else : print("密码含有其它符号,注册失败")