实现功能:
1.注册系统
2.根据注册的信息进行登录
3.登录时密码输入错误五次自动锁定
4.通过注册时的绑定手机号,可以对被锁定用户进行解锁
-----------------------------------注册模块--------------------------------------
from login import login
from fourcode import code
import re # 引入正则模块
import hashlib # 加密模块
def newuser(code): # code用来接收验证码
while True:
print(" ----- 会员注册界面 ------")
print(" ")
name = re.match("([a-z]|[A-Z]){3,}", input("注册需要的用户名(大于三位全英文): "))
passwd = re.match("\d{6,}", input("请设置密码(必须大于6位全数字):"))
phone = re.match("1\d{10}",input("请绑定您的手机号用于找回密码: "))
age = re.match("\d\d",input("请输入您的年龄:"))
if name and passwd and phone and age: # 判断用户名密码电话和年龄是否都符合正则
name=name.group()
passwd = passwd.group()
phone = phone.group()
age = age.group()
print(f"验证码: [{code}]") # 显示验证码
while True:
input_code = input("请输入验证码(区分大小写): ") # 判断输入的验证码是否正确
if input_code == code: # 如果输入正确,注册成功
print("-"*20)
print("注册成功,欢迎成为会员")
print("-" * 20)
mdpasswd = hashlib.md5(f'{passwd}'.encode())
md5passwd = (mdpasswd.hexdigest()) # 把用户设置的密码进行加密
with open("file_name.txt","a",encoding="utf