python第二十三天-----作业中

时间:2021-09-12 20:44:50
 #!usr/bin/env python
#-*-coding:utf-8-*-
# Author calmyan
import os ,sys,time from core import transaction #包含记账\还钱\取现等所有的与账户金额相关的操作
from core import user_pass #用户名检测相关
from core import log_file #日志相关 def login():#开始函数
# time_format='%y-%m-%d %X'#定义时间格式
# times=time.strftime(time_format)#定义时间
print("Welcome to python ATM".center(60,'*'))
while True:
print('''================================================
1 >>>> 用户登陆.
2 >>>> 直接退出.
================================================
''') foo=input('请选择您要的操作:')
if foo=='':
_user_name= user_pass.user_pass()#将通过验证的用户名赋于变量
data=transaction.user_info(_user_name)#调用帐户查询函数
if data['状态']:
print('\033[31;1m对不起您的帐户被冻结,不能进行相关操作,请与客服联系!\033[0m')
continue
print('尊敬的:\033[32;1m%s\033[0m 欢迎登陆'.center(50,'=')%_user_name)
while True:
print(''' 欢迎使用自动ATM柜员机
1 >>> 帐户信息查询. 2 >>> 帐户转帐.
3 >>> 现金提取. 4 >>> 还款.
5 >>> 退出.
''')
options=input('请按提示操作:')
if options=='':
while True:
transaction.info_user(_user_name)##调用帐户查询函数用户操作日志,传入内容
break
elif options=='':
data=transaction.user_info(_user_name)#调用帐户查询函数
print(transaction.info_format(data))#用户信息输出格式化函数
print('欢迎使用自助转帐'.center(60,'='))
card=input('按\033[31;1mq/Q\033[0m返回 输入对方的卡号:')
if card=='q' or card=='Q':
continue
if card.isdigit():#检测输入是否为整数
card=int(card)#转为int
if card==data['id']:
print('\033[41;1m您所输入的卡号是自己卡号,请重新输入!\033[0m')
transaction.transfer(card,_user_name)##调用转帐的函数
continue
else:
print('您的输入不正确,请重新输入!')
pass elif options=='':
while True:
data=transaction.user_info(_user_name)#调用帐户查询函数
print(transaction.info_format(data))#用户信息输出格式化函数
mony=input('按\033[31;1mq/Q\033[0m返回 请输入要提现的金额:')
if mony=='q' or mony=='Q':
break
if mony.isdigit():#检测输入是否为整数
mony=int(mony)#转为int
transaction.cash(mony,_user_name)##调用取现的函数
continue
else:
print('您的输入不正确,请重新输入!')
pass
elif options=='':
while True:
data=transaction.user_info(_user_name)#调用帐户查询函数
print(transaction.info_format(data))#用户信息输出格式化函数
s_mony=data["最高额度"]-data["帐户信用余额"]
print('本期总共需要还款:要\033[31;1m%s\033[0m'%s_mony)
mony=input('按\033[31;1mq/Q\033[0m返回,请输入要还款的金额:')
if mony=='q' or mony=='Q':
break
if mony.isdigit():#检测输入是否为整数
mony=int(mony)#转为int
transaction.also_money(mony,s_mony,_user_name,data)#还款函数
pass
else:
print('您的输入不正确,请重新输入!')
pass elif options=='':
exit()
else:
continue elif foo=='':
exit()
else:
print('请按提示操作!')
pass