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

python信用卡操作

时间:2019-06-27 18:00:17      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:com   登陆   pytho   log   return   out   turn   time   ret   

import datetime

user_dict = dict() # 用来存储用户的账号


# 注册系统:
def registered():
try:
print(‘welcome to register ATM system‘)
registered_user = input(‘请输入您的账号:‘)
registered_pwd = int(input(‘请输入您密码:‘))
user_dict[‘user‘] = registered_user
user_dict[‘pwd‘] = registered_pwd
print(‘你的账号【{}】已注册成功,欢迎您登陆‘.format(registered_user))
except Exception as e:
print(e)


# 登陆系统:login
def login():
try:
print(‘welcome to login ATM system‘)
login_user = input(‘请输入您的账号:‘)
login_pwd = int(input(‘请输入您密码:‘))
if login_user == user_dict[‘user‘] and login_pwd == user_dict[‘pwd‘]:
print(‘welcome to my ATM system:{}‘.format(login_user))
user_money = int(input(‘请输入您的金额:‘))
user_dict[‘money‘] = user_money
elif login_user != user_dict[‘user‘] or login_pwd != user_dict[‘pwd‘]:
print(‘你的登陆账号或密码有误,请检查后重新登陆‘)
return user_dict[‘user‘], user_dict[‘money‘]
except Exception as e:
print(e)


def show_menu(login_user, user_money):
while True:
try:
print(‘1.账户信息‘)
print(‘2.取款‘)
print(‘3.还款‘)
print(‘4.转账‘)
print(‘5.账单‘)
print(‘6.退出‘)
user_choice = int(input(‘请输入您的选择:‘))
if user_choice == 1:
print(‘账户:{} 金额:{}‘.format(login_user, user_money))
time1 = datetime.datetime.today()
time1 = time1.strftime("%Y/%m/%d %H:%M:%S")
elif user_choice == 2:
out_money = int(input(‘请输入您要提现的金额:‘))
time2 = datetime.datetime.today()
time2 = time2.strftime("%Y/%m/%d %H:%M:%S")
if out_money > user_money:
print(‘对不起,余额不足‘)
else:
user_money = user_money - out_money
print(‘提现{}成功,余额{}‘.format(out_money, user_money))
elif user_choice == 3:
in_money = int(input(‘请输入您要还款的额度:‘))
user_money = user_money + in_money
time3 = datetime.datetime.today()
time3 = time3.strftime("%Y/%m/%d %H:%M:%S")
print(‘还款:{} 余额{}‘.format(in_money, user_money))
elif user_choice == 4:
Transfer_user = input(‘请输入您要转账的用户名:‘)
Transfer_money = int(input(‘请输入您要转账的金额:‘))
user_money = user_money - Transfer_money
time4 = datetime.datetime.today()
time4 = time4.strftime("%Y/%m/%d %H:%M:%S")
print(‘{}转账成功,转账金额{},您的余额为{}‘.format(Transfer_user, Transfer_money, user_money))
elif user_choice == 5:
print(‘您的账单信息如下:‘)
print(‘您的余额是:{},time{}‘.format(user_money, time1))
print(‘您的提现额是:{},time{}‘.format(out_money, time2))
print(‘您的还款额是:{},time{}‘.format(in_money, time3))
print(‘您的转账额是:{},time{}‘.format(Transfer_money, time4))
elif user_choice == 6:
print(‘欢迎下次光临本系统‘)
exit()
except Exception as e:
print(e)


if __name__ == ‘__main__‘:
registered()
user_dict[‘login_user‘], user_dict[‘money‘] = login()
show_menu(user_dict[‘login_user‘], user_dict[‘money‘])

python信用卡操作

标签:com   登陆   pytho   log   return   out   turn   time   ret   

原文地址:https://www.cnblogs.com/victorstudy/p/11098476.html

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