home_page = """
❀❀================❀❀
账号:******
密码:******
注册 登录
❀❀================❀❀
请选择:
1.注册 2.登录 3.退出
"""
def reg_num(str1):
list1 = []
with open('bb.txt', 'r', encoding='utf-8') as f:
x = f.readline()
while x:
list1.append(x)
x = f.readline()
# list1 = list[x]
if len(list1)==0:
str2 = input('密码:')
with open('bb.txt','a',encoding='utf-8') as f:
f.write(str1+'\n')
f.write(str2+'\n')
else:
for index in range(0,len(list1),2):
if list1[index] == str1+'\n':
print('此账号已被注册')
else:
str2 = input('密码:')
with open('bb.txt', 'a', encoding='utf-8') as f:
f.write(str1+'\n')
f.write(str2+'\n')
print('注册成功')
def ter_num(str1):
list1 = []
with open('bb.txt', 'r', encoding='utf-8') as f:
x = f.readline()
while x:
list1.append(x)
# print(list1)
x = f.readline()
# with open('bb.txt', 'r', encoding='utf-8') as f:
# list1 = list[f.read()]
if str1+'\n' not in list1:
print('无此账号,请重新输入')
else:
while 1:
str2 = input('密码:')
for index in range(0,len(list1),2):
if list1[index] == str1+'\n':
while 1:
if list1[index+1] == str2+'\n':
print('登录成功')
break
else:
print('密码错误')
break
break
break
with open('bb.txt', 'r', encoding='utf-8') as f:
x = f.readline()
print(x)
while 1:
print(home_page)
num1 = int(input('请输入:'))
if num1 == 1:
str1 = input('账号:')
reg_num(str1)
input('任意键返回')
elif num1 == 2:
str1 = input('账号:')
ter_num(str1)
input('系统维护中,任意键返回')
else:
break