额度15000
可以提现,手续费%5
每月最后一天出账单(每月30天),写入文件
记录日常消费流水(交易日,交易摘要,金额)
提供还款接口
主程序 bill_main_models.py #coding:UTF-8 import sys import datetime import time def withdraw_mode(limit): f_file = ‘bill_detail.txt‘ try: num = int(raw_input(‘Please input your withdraw number:‘)) except: print ‘Please input a valid number‘ #continue 不在循环中 sys.exit() true_num = num + num * 0.05 if true_num <= limit: print ‘OK,give you the money‘ limit = limit - true_num print ‘now you have ‘,limit item = str(datetime.date.today()) + ‘ ‘ + ‘withdraw‘ + ‘ ‘ + str(true_num) f = file(f_file,‘a‘) f.write(item) f.write(‘\n‘) f.close() return limit else: print ‘you want too much money,now you have ‘,limit def pay_by_card_mode(limit): f_file = ‘bill_detail.txt‘ try: name = raw_input(‘Please input your product name:‘) num = int(raw_input(‘Please input your product money:‘)) except: print ‘Please input a valid name or number‘ sys.exit() if num <= limit: print ‘OK,you get it‘ limit = limit - num print ‘now you have ‘,limit item = str(datetime.date.today()) + ‘ ‘ + ‘pay_by_card‘ + ‘ ‘ + str(num) f = file(f_file,‘a‘) f.write(item) f.write(‘\n‘) f.close() return limit else: print ‘you want too much money,now you have ‘,limit def repayment_mode(limit): f_file = ‘bill_detail.txt‘ try: num = int(raw_input(‘Please input your back money:‘)) except: print ‘Please input a valid number‘ sys.exit() print ‘OK,you back it‘ limit = limit + num print ‘now you have ‘,limit item = str(datetime.date.today()) + ‘ ‘ + ‘repayment‘ + ‘ ‘ + str(num) f = file(f_file,‘a‘) f.write(item) f.write(‘\n‘) f.close() return limit limit = 15000 #这应该写在文件里的 while True: print ‘‘‘ 1 withdraw 2 pay by card 3 repayment 4 exit ‘‘‘ try: choose = int(raw_input(‘Please input your number:‘)) except: print ‘Please input a valid number‘ continue if choose == 1: limit = withdraw_mode(limit) elif choose == 2: limit = pay_by_card_mode(limit) elif choose == 3: limit = repayment_mode(limit) elif choose == 4: sys.exit() else: print ‘Please input a valid number‘ continue 月初出账程序 bill_mon_sum.py #coding:UTF-8 import datetime import time import sys def mon_sum(bill_card): s = 0 for i in bill_card: i = float(i) s = s + i return s while True: if datetime.date.today().strftime(‘%d‘) == ‘23‘: pay_by_card_mon = [] withdraw_mon = [] repayment_mon = [] f_file = ‘bill_detail.txt‘ f = file(f_file) for line in f.readlines(): line = line.strip().split() if line[1] == ‘pay_by_card‘: pay_by_card_mon.append(line[2]) elif line[1] == ‘withdraw‘: withdraw_mon.append(line[2]) elif line[1] == ‘repayment‘: repayment_mon.append(line[2]) else: print ‘this bill is no defiened‘ pass f.close() pay_by_card_mon_sum = str(datetime.date.today()) + ‘ ‘ + ‘pay_by_card_mon‘ + ‘ ‘ + str(mon_sum(pay_by_card_mon)) withdraw_mon_sum = str(datetime.date.today()) + ‘ ‘ + ‘withdraw_mon‘ + ‘ ‘ + str(mon_sum(withdraw_mon)) repayment_mon_sum = str(datetime.date.today()) + ‘ ‘ + ‘repayment_mon‘ + ‘ ‘ + str(mon_sum(repayment_mon)) f_file = ‘bill_mon.txt‘ f = file(f_file,‘a‘) f.write(pay_by_card_mon_sum) f.write(‘\n‘) f.write(withdraw_mon_sum) f.write(‘\n‘) f.write(repayment_mon_sum) f.write(‘\n‘) f.close() print ‘1111111111‘ time.sleep(60*60*24) else: print ‘222222‘ time.sleep(60*60*24) continue
原文地址:http://8588103.blog.51cto.com/8578103/1664705