home_page = """
??================??
賬號(hào):******
密碼:******
注冊(cè) 登錄
??================??
請(qǐng)選擇:
1.注冊(cè) 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('此賬號(hào)已被注冊(cè)')
else:
str2 = input('密碼:')
with open('bb.txt', 'a', encoding='utf-8') as f:
f.write(str1+'\n')
f.write(str2+'\n')
print('注冊(cè)成功')
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('無此賬號(hào),請(qǐng)重新輸入')
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('密碼錯(cuò)誤')
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('請(qǐng)輸入:'))
if num1 == 1:
str1 = input('賬號(hào):')
reg_num(str1)
input('任意鍵返回')
elif num1 == 2:
str1 = input('賬號(hào):')
ter_num(str1)
input('系統(tǒng)維護(hù)中,任意鍵返回')
else:
break