输入用户名,密码,邮箱,用户名不能含有非法字符,然后输入验证码(不分大小写),成功则打印出来:
s = "用户名\t密码\t邮箱\n"
while True:
v = input(">>>请创建用户名: ")
if v.count("草"):
m = v.replace("草","*")
print(m,"含有非法字符")
continue
if v.count("叼"):
m = v.replace("叼","*")
print(m, "含有非法字符")
continue
if v.count("爸"):
m = v.replace("爸","*")
print(m, "含有非法字符")
continue
if v.count("奶"):
m = v.replace("奶","*")
print(m, "含有非法字符")
continue
if v.count("草你爸爸"):
m = v.replace("草你爸爸","****")
print(m, "含有非法字符")
continue
else:
m = v
v1 = input(">>>请输入密码: ")
v2 = input(">>>请输入邮箱: ")
template = "{0}\t{1}\t{2}\n"
v3 = template.format(m,v1,v2)
s = s + v3
def check_code():
import random
checkcode = ""
for i in range(4):
current = random.randrange(0,4)
if current != i:
temp = chr(random.randint(65,90))
else:
temp = random.randint(0,9)
checkcode += str(temp)
return checkcode
code = check_code()
print("验证码是:",code)
while True:
p = input(">>>请输入验证码")
if p.upper() == code:
print("注册成功")
break
else:
print("验证码不正确,请重新输入。")
print(s.expandtabs(20))
break