注册(regedit.py)
# -*- coding: utf-8 -*-
#__author__:Selid
#__date__:2018/12/21
name=input('请输入用户名').strip()
pwd=input('请输入密码').strip()
with open('account',mode='a') as obj:
obj.write(name)
obj.write('*')
obj.write(pwd+'\n')
print ('注册成功,欢迎登陆')
with open('account', mode='r') as f:
for i in f.readlines():
print(i.split('*'))
登陆(login.py)
# -*- coding: utf-8 -*-
#__author__:Selid
#__date__:2018/12/21
flag=True
count=1
li=[]
while flag:
name = input('用户名').strip()
pwd = input('密码').strip()
mid=[name,pwd]
with open('account', mode='r',encoding='utf-8') as f:
for i in f.readlines():
acc = i.split('*')
acc[1]=acc[1][:-1]
li.append(acc)
if mid in li:
print('登陆成功')
flag = False
else:
count += 1
if 3-count >=0:
print('您输入的用户名或密码错误,请重新输入,您还有{}次机会'.format(4-count))
else:
q=input('您还想登陆吗Y/N')
if q.upper()=='Y':
count=1
if count>3:
flag=False
else:
print('-------------------')