m1.py文件 from functools import wraps def outter1 ( func ): wraps ( func ) def wrapper ( * args , * * kwargs ): login = 1 while login : Inp_zz = input ( '登录 1/注册 2: ' ). strip () if Inp_zz == '1' : Inp_User = input ( '请输入用户
m1.py文件
from functools import wrapsdef outter1(func):
wraps(func)
def wrapper(*args,**kwargs):
login = 1
while login:
Inp_zz = input('登录 1/注册 2: ').strip()
if Inp_zz == '1':
Inp_User = input('请输入用户: ').strip()
Inp_Pass = input('请输入密码: ').strip()
with open('a.txt', mode='rt', encoding='utf-8') as f3:
for g in f3:
username, password = g.strip().split(':')
if Inp_User == username and Inp_Pass == password:
print('登录成功')
login = 0
break
else:
print('用户或密码错误,请重新登录')
elif Inp_zz == '2':
with open('a.txt', mode='rt', encoding='utf-8') as f1:
Inp_rtu = input('用户: ').strip()
Inp_rtp = input('密码: ').strip()
for i in f1:
res1, _ = i.strip().split(':')
if Inp_rtu.startswith(res1):
count = 1
break
else:
count = 2
if count == 1:
print('用于已存在,请重新注册')
continue
elif count == 2:
if len(Inp_rtu) != 0 and len(Inp_rtp) != 0:
with open('a.txt', mode='r+b') as f2:
f2.seek(0, 2)
us = '{}:{}\n'.format(Inp_rtu, Inp_rtp)
f2.write(us.encode('utf-8'))
print('注册成功,请重新登录')
else:
print('无效用户')
print()
break
else:
print('非法输入')
continue
res=func(*args,**kwargs)
return res
return wrapper
m2.py文件
from functools import wrapsdef outter2(func):
wraps(func)
def wrapper(*args,**kwargs):
def f1():
print('转账功能')
def f2():
print('提现功能')
def f3():
print('充值功能')
def f4():
print('存入功能')
dict_func = {
'0': ('退出功能', None),
'1': ('转账功能', f1),
'2': ('提现功能', f2),
'3': ('充值功能', f3),
'4': ('存入功能', f4)
}
while True:
[print(i.rjust(3, ' '), dict_func[i][0]) for i in dict_func ]
res = input('请输入编号: ').strip()
if not res.isdigit():
print('请输入数字编号!!!')
continue
if res == '0':
break
dict_func[res][1]() if res in dict_func else print('不存在该功能')
res = func(*args,**kwargs)
return res
return wrapper
run.py文件
from m1 import outter1from m2 import outter2
def index():
print('欢迎下次再来!!!')
res=index()
加油!!!!