python ---待修改,ATM取款系统

来源:互联网 发布:免费数据库同步软件 编辑:程序博客网 时间:2024/05/29 17:50

待修改,ATM取款系统

root@kali:~/python/atm# cat atm.py #!/usr/bin/python# --*-- coding:utf-8 --*--import tabcreditcradinitmoney = 15000def buy():#商城购物    f_shoplist = file('shoplist.txt')    products = []    prices = []    buyshop = []    for p in f_shoplist.readlines():        new_p = p.split()        products = new_p[0]        prices = new_p[1]        print products,prices    while True:        choice = raw_input('请输入要购买的产品:')        f_choice = choice.strip()        print f_choice  def deposit(cunkuanmoney,cunkuantotalmoney):#存款    #cunkuanmoney = raw_input('请输入你要存款的金额:')    x = cunkuanmoney    print type(x)    cunkuantotal = 0    f_cunkuan = file('xiaofeiqingdan.txt','r+')    f_cunkuan.write('你存款的金额是:\t')    f_cunkuan.flush()    f_cunkuan.write(x)    f_cunkuan.flush()    y = cunkuantotalmoney + x        print '你现在可用的金额为%d' % y    f_cunkuan.write('\n可用金额是:\t')    f_cunkuan.flush()    f_cunkuan.write(y)    f_cunkuan.flush()    f_cunkuan.close()def withdraw(qukuanmoney):#取款        #creditcarddrawmoney = int(raw_input('请输入你要取款的金额:'))        shouxifeimoney =  qukuanmoney*0.05        print '你取款的金额%d的手续费为%d'%(qukuanmoney,shouxifeimoney)        withdrawlfetmoney = 15000 - qukuanmoney - shouxifeimoney        print '你现在可用余额为%d' %  withdrawlfetmoneydef creditcardmoneyleft(xiaofeimoney,liximoney,totalmoney):#查询余额        totalmoney = xiaofeimoney + liximoney        print '-------------------------------'        print '你的消费的金额为% d'% xiaofeimoney        print '你的利息累加的金额为% d'% liximoney        print '你的总可用的余额为% d'% totalmoney        print '-------------------------------'def searchbill():    print 'searchbill()''''修改密码要求:旧密码验证后才能提示修改新密码新密码需输入两次。两次相同即可通过密码长度必须在6位以上'''def modpassword():    print 'modpassword()'    pd_old = raw_input('请输入信用卡的旧的密码:')    if pd_old == '123456':        moduser = []        modpd = []        moduserinfo = []        f1 = open('userinfo.txt','r')        #print type(f1)        for p in f1.readlines():            new_p = p.split()            moduser.append(new_p[0])            modpd.append(new_p[1])        f1.close()        print moduser,modpd        moduserinfo.append(moduser[0])        moduserinfo.append(modpd[0])        print moduserinfo        pd_new1 = raw_input('请输入新信用卡密码,至少6位以上:')        pd_new2 = raw_input('请再次输入新信用卡密码,至少6位以上:')        if pd_new1 == pd_new2:            f2 = open('userinfo.txt','r+')            f2.write(moduserinfo[1])            f2.close()            print '恭喜您!信用卡密码修改成功!'        else:            print '你输入的两次新的信用卡密码不相同!请重新输入!'    else:        print '你输入的信用卡密码错误,请重新输入!''''转账要求:额度不能低于100元,额度不能高于20000元必须为100的整数倍,扣除手续费10%将该笔记录写入账单中'''def tranfer():    print 'tranfer()'def gongneng():    print '''请选择操作的业务:(输入q退出系统)         (1) 消费商城购物         (2) 查询余额         (3) 存款         (4) 取款         (5) 转账         (6) 查询账单         (7) 修改密码'''    while True:        choice = raw_input('请输入需要操作业务编号:')        f_choice = choice.strip()        if f_choice != 'q':            if f_choice == '1':                buy()            elif f_choice == '2':                creditcardmoneyleft(15000,0,15000)            elif f_choice == '3':                deposit()            elif f_choice == '4':                withdraw(234)            elif f_choice == '5':                tranfer()            elif f_choice == '6':                searchbill()            else:                modpassword()        else:            print '你已经退出中国银行ATM取款系统!欢迎下次光临!'            exit()while True:    user = []    pd = []    file = file('userinfo.txt','r+')    for p in file.readlines():        new_p = p.split()        user.append(new_p[0])        pd.append(new_p[1])    file.close()    #print user[0],pd[0]        creditcard = raw_input('请输入信用卡卡号:')        #f_creditcard = creditcard.strip()    if creditcard == user[0]:        creditcardpd = pd[0]                while True:                        creditcardpassword = raw_input('请输入信用卡密码:')                        #f_creditcardpassword = creditcardpassword.strip()                        if creditcardpassword != creditcardpd:                                print '输入的密码%s不对,请重新输入密码' % creditcardpassword                        else:                                print '恭喜你!欢迎进入中国银行ATM取款系统!'                                gongneng()    else:                print '输入的信用卡号%s错误!请重新输入的你的信用卡号码!' % creditcardroot@kali:~/python/atm# 
原创粉丝点击