码迷,mamicode.com
首页 > 编程语言 > 详细

python基础之ATM-8

时间:2017-10-29 11:11:27      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:操作   rom   else   status   lock   core   and   add   成功   

import json
from core import accounts
import datetime
‘‘‘
本模块是manage,实现的是管理员的入口,进行添加账户、修改额度,冻结账户
‘‘‘
def manage(_user,_pass):
‘‘‘
本函数实现了信息账户管理,默认用户名和密码都是admin
:param _user:
:param _pass:
:return:
‘‘‘
if _user == "admin" and _pass == "admin":
print("欢迎%s登陆信用卡管理系统"%_user)
print("1.添加账户 2.用户额度 3.冻结账户")
choose = input("请输入你的操作 >>>")
if choose == "1":
add_account()
elif choose == "2":
user_limit()
elif choose == "3":
lock_account()
elif choose == "q":
exit()
else:
print("输入错误")

def add_account():
acc_acount = {}
name = input("请输入姓名 >>>").strip()
account = input("请输入账号 >>>")
_pass = input("请输入密码 >>>")
limit = input("请输入账户的额度 >>>")
if limit.isdigit():
limit = int(limit)
else:
print("输入错误")
acc_acount["name"] = name
acc_acount["account"] = account
acc_acount["engine"] = str(datetime.date.today() + datetime.timedelta(days= 365*3))
print(acc_acount["engine"])
acc_acount["pass"] = _pass
acc_acount["limit"] = limit
acc_acount["used"] = 0
acc_acount["cancash"] = acc_acount["limit"] / 2
acc_acount["status"] = "normal"
accounts.dump(acc_acount)
print("信用卡账户%s添加成功"%account)

def user_limit():
account = input("请输入要调整额度的账号 >>>")
acc_account = accounts.load(account)
if acc_account:
print("%s账户的当前额度是:%d"%(acc_account["account"],acc_account["limit"]))
new_limit = input("请输入调整后的额度 >>>>")
if new_limit.isdigit():
new_limit = float(new_limit)
acc_account["limit"] = new_limit
accounts.dump(acc_account)
else:
print("该账户不存在")

def lock_account():
account = input("请输入要冻结的账号 >>>")
acc_account = accounts.load(account)
if acc_account:
choise = input("是否确认冻结该账号(y/n)")
if choise == "y":
acc_account["status"] = "lock"
accounts.dump(acc_account)
else:
print("该账户不存在")

if __name__ == ‘__main__‘:
user = input("请输入用户名 >>>")
_pass = input("请输入密码 >>>")
while True:
manage(user,_pass)

python基础之ATM-8

标签:操作   rom   else   status   lock   core   and   add   成功   

原文地址:http://www.cnblogs.com/hqd2008/p/7749382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!