本文来源吾爱破解论坛
流感期间,在家为祖国做贡献,闲来无事学习python大法,由于没有编程基础,学了一星期,才终于完成了一个自主小程序。
写了将近2个小时,不停的调试,终于完成了。
各位大佬莫要嘲笑...
下面是程序源码:
[Python] 纯文本查看 复制代码
import time banksql=[ {"card_id":"6228881234567000","passwd":"100001","name":"张飞","money":38492.7,"telephone":"18888888880"}, {"card_id":"6228881234567001","passwd":"100002","name":"关羽","money":895889558.5,"telephone":"18800244887"}, {"card_id":"6228881234567002","passwd":"100003","name":"土拔鼠","money":32767,"telephone":"18888888003"}, {"card_id": "6228881234567003", "passwd":"100004","name":"关云长","money":38492.7,"telephone":"18888888004"}, {"card_id": "6228881234567004", "passwd":"100005","name":"宋江","money":38492.7,"telephone":"18888888007"} ] print("欢迎使用大老虎ATM自动存取款机") time.sleep(1) inputid=input("请输入您的老虎卡的卡号:") inputpassword=input("请注意遮挡键盘,输入您的老虎卡密码:") myid=-1 for a,b in enumerate(banksql): if b["card_id"]==inputid and b["passwd"]==inputpassword: myid = a print("亲爱的",b["name"],",您已成功登录!") while True: mychoise=input(""" -----------------ATM主菜单------------------ 1,取款 2,存款 3,本行转账 4,查询余额及预留信息 5,退出 -------------------------------------------- 请选择您的操作:""") #用户选择部分-取款 if mychoise=="1": print( b["name"], "的老虎卡账户余额为:", b["money"]) cuowu = 0 while cuowu<3: qmoney=int(input("请输入您的取款金额:")) if qmoney % 100 == 0: if qmoney<=banksql[myid]["money"]: print("您取款的金额为", qmoney, "正在取款!请稍后") time.sleep(3) banksql[myid]["money"] -= qmoney print("恭喜您!", qmoney, "元取款成功!", b["name"], ",请取出您的钞票!") time.sleep(2) print("取出后", b["name"], "的老虎卡账户余额为:", b["money"]) time.sleep(2) break else: print("您的余额不足!请重新输入!") elif cuowu < 2: print("取款金额错误,请重新输入!") cuowu += 1 else: print("取款金额错误次数过多,正在退出菜单") cuowu+=1 time.sleep(2) break #存款操作 elif mychoise=="2": print("正在进行存款操作,请稍后。。。") time.sleep(1) cuowucishu=0 while cuowucishu<3: cunrumoney=int(input("请输入您的存款金额:")) if cunrumoney%100==0: print("您存入的金额为",cunrumoney,"正在存入!") time.sleep(3) banksql[myid]["money"]+=cunrumoney print("恭喜您!",cunrumoney,"元已经存入",b["name"],"的账户!") time.sleep(2) print("存入后", b["name"], "的老虎卡账户余额为:", b["money"]) break elif cuowucishu < 2: print("存入金额错误,请重新输入!") cuowucishu+=1 else : print("存入金额错误三次,正在退出菜单") cuowucishu += 1 break elif mychoise =="4": print("正在查询余额,请稍后:") print("已查询到",b["name"],"的老虎卡余额为:",b["money"],",联系电话:",b["telephone"]) time.sleep(2) #转账操作 elif mychoise == "3": print("正在进行转账操作!") zhanghao=input("请输入您要转入的银行卡账户:") if zhanghao!=b["card_id"]: zzmoney=int(input("请输入您的转账金额:")) zzid=-1 if zzmoney<=banksql[myid]["money"]: for c,d in enumerate(banksql): if d["card_id"] == zhanghao: zzid = c print("您要转入的账户为", d["name"], ",转入金额为",zzmoney) go=input("确认无误请按Y继续转账!其他键退出!") if go=="Y" or go=="y": time.sleep(1) print("当前", b["name"], "的老虎卡账户余额为:", b["money"]) print("当前", d["name"], "的老虎卡账户余额为:", d["money"]) print("正在进行转账操作,请稍后!") time.sleep(1) banksql[myid]["money"] -= zzmoney print("您的账户已扣除转账金额",zzmoney,"元!正在转入,",d["name"],"账户!请稍后!") time.sleep(1) banksql[zzid]["money"] += zzmoney print("已转入",d["name"], "共",zzmoney, "元!") time.sleep(1) print("转账后", b["name"], "的老虎卡账户余额为:", b["money"]) print("当前", d["name"], "的老虎卡账户余额为:", d["money"]) time.sleep(3) break else: break else: continue if zzid == -1: print("您输入的账户未找到!") else: print("您的余额不足!请充值后再转账!") else: print("您不可以给自己转账!") elif mychoise =="5": print("正在退出") time.sleep(3) break else: continue if myid==-1: print("对不起,您的老虎卡未注册,请到营业厅办理注册!") print("欢迎您下次再来!")
版权声明:
本站所有资源均为站长或网友整理自互联网或站长购买自互联网,站长无法分辨资源版权出自何处,所以不承担任何版权以及其他问题带来的法律责任,如有侵权或者其他问题请联系站长删除!站长QQ754403226 谢谢。