Implementing credit card consumption mechanism through Python

Source: Internet
Author: User
Tags date1

Functional Requirements:
1. Quota 15000
2. It can be shown that the handling fee is 5%
3 The last day of the month is the bill, write a file
4. Record monthly daily consumption flow (no daily consumption)

5. Write the repayment for the current period


Python Source code:

 #!/usr/bin/env python# encoding=utf-8# author:sihaogongyuan# date:2015-4-13#  filename:atm-py# desc:atm-py################################################ #import  sysimport  Ossys.path.append ('/tmp/python/') import tabimport time############################################## # # #credit_line =int (15000) old_money=int (15000) #print  type (credit_line) #counter_fee =0.05fee_rate=0.05###### ########################################### #date =time.strftime ('%y-%m-%d %h:%m:%s ') ###################### ########################## #date1 =time.strftime ('%y-%m-%d-%h:%m:%s ') f=file ('%s.log '% (date1), ' W ') F.close () f=file ('%s.log '% (date1), ' a ') f.write (' Transaction date \ t ' transaction summary \ t amount \ t fee \ t credit limit \ n ') ###### #取现 ##################################### #def  qu_xian ():  global credit_line  global fee_rate  #date =os.system ("date   ' +%f:%t ')   #print  date date=time.strftime ('%y-%m-%d %h:%m:%s ')  quxian_money=int (Raw_input (' pleaseEnter cash amount: '). Strip ())   #print  quxian_money,type (Quxian_money)  while quxian_money== ":     continue   #print  quxian_money,type (Quxian_money)  if 0<quxian_ money<=credit_line:   #定义手续费counter_fee   counter_fee=quxian_money*fee_rate   credit_line=credit_line-quxian_money-counter_fee  print  ' \033[32m has been taken%d yuan, the handling fee is%d yuan, the credit limit is%d Yuan \033[0m ' % (quxian_money,counter_fee,credit_line)   f.write ('%s\t withdrawal \t%s\t%d\t%d\n '% (date,quxian_money,counter_ Fee,credit_line))   f.flush ()  else:  print  ' \033[31m Cash amount%d is not within the credit limit, withdrawal failed \033[0m '% ( Quxian_money) ###### #刷卡 ####################################### #def  shua_ka ():  global credit_line   #date =os.system ("date  ' +%f:%t '")  date=time.strftime ('%y-%m-%d %h:%m:%s ')  shuaka_ Money=int (raw_input (' Please enter consumption amount: '). Strip ())  if 0<shuaka_money<=credit_line:  credit_ Line=credit_line-shuaka_money  print  ' \033[32m has consumed%d yuan, credit limit is%d \033[0m '% (shuaka_money,credit_line)    #f. Write ( Os.system (' Date '), ' \ t ', ' swipe ', ' \ t ', shuaka_money,0)   f.write ('%s\t swipe \t%s\t0\t%d\n '% (Date,shuaka_money, Credit_line))   f.flush ()  else:  print  ' \033[31m consumption amount%d is not within the credit limit, consumption failed \033[0m '% ( Shuaka_money) ####### #存钱 ###################################### #def  cun_qian ():  global credit_ line  #date =os.system ("date  ' +%f:%t '")  date=time.strftime ('%y-%m-%d %h:%m:%s ')  cun_ Qian_money=int (raw_input (' Please enter your deposit amount: '). Strip ())  if cun_qian_money>0:  credit_line=credit_ line+cun_qian_money  print  ' \033[32m deposit%d successful, current credit limit is:%d '% (cun_qian_money,credit_line)    F.write ('%s\t save \t-%s\t0\t%d\n '% (date,cun_qian_money,credit_line))   f.flush ()  else:   print  ' \033[31m Access amount%d does not conform to specification, deposit failed \033[0m '% (Cun_qian_money) ########## #main ################################## # #print   ' \ t Welcome to ATM system ' WHile true:  #credit_line =int (15000)   #fee_rate =0.05 choice=raw_input (' Please enter what you want to do (withdraw, consume, save, withdraw) : '). Strip ()  if choice== ':     continue if choice== ' withdrawal '  or  choice== ' withdrawal ':   qu_xian ()   continue elif choice== ' credit card '  or choice== ' consumption ':   shua_ka ()   continue elif choice== ' save '  or choice== ' deposit ':   Cun_qian ()   continue elif choice== ' exit '  or choice== ' exit ':  break  else:  print  ' non-compliant operation, please re-select '   continue################################################ # # #f. Write (' \033[32m currently available credit limit:%s\n\033[0m '% (credit_line)) F.flush () f.write (' \033[32m current repayment amount is%d\n\033[0m '% (old_ Money-credit_line)) F.flush () F.close () f=file ('%s.log '% (date1), ' R ') Print f.read () ########################## #########################


Implementing credit card consumption mechanism through Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.