==============一.注册界面================
page = """=============================
^(* ̄(oo) ̄)^欢迎进入注册界面:
1.账号
2.密码
============================="""
#获取本地账号函数:
def name_get(str1):
str2 = ''
for index in range(len(str1)):
str2 += str1[index]
if str1[index] == '/':
break
return str2
#注册用户函数:
def ddf():
#第一次进入创建txt文件
with open('user.txt', 'a', encoding='utf-8') as f:
pass
#输入账号判断是否存在,若存在则提示存在
account_number = input('请输入账号:')
with open('user.txt', encoding='utf-8') as f:
user = f.readline()
while user:
if account_number + '/' == name_get(user):
print('该账号已有,请重新输入')
break
user = f.readline()
else:
password = input('请输入密码:')
with open('user.txt', 'a', encoding='utf-8') as f:
user = f.write('%s\n' % (account_number + '/' + password))
print('注册成功')
print(page)
ddf()
==============二.登录界面================
page = """=============================
^(* ̄(oo) ̄)^欢迎进入登录界面:
1.账号
2.密码
============================="""
def dyf():
account_number = input('请输入账号:')
password = input('请输入密码:')
a = account_number + '/' + password
with open('user.txt',encoding='utf-8') as f:
user = f.readline()
while user:
if a + '\n' == user:
print('成功进入')
break
user = f.readline()
else:
print('账户或者密码输错')
print(page)
dyf()
网友评论