The requirement analysis is as follows: The difficulty here is the replacement of the cash. My idea here is that whenever cash is used. Turns the line of user files into a list, converted to int type add minus: The result is replaced with the Fileinput module after the results are obtained. The following steps journal are still thinking. Of course, the withdrawal fee conversion is very simple, I have not listed here, roughly has been completed. Cash withdrawal. Recharge. Shopping and other three functions: (because it is operational, so the code is very rough)
650) this.width=650; "style=" width:721px;height:182px; "title=" QQ picture 20141014082730.jpg "Src=" http://s3.51cto.com/ Wyfs02/m00/4c/76/wkiol1q95apq5iyraahrtcwbpmq162.jpg "width=" 1046 "height=" 181 "alt=" Wkiol1q95apq5iyraahrtcwbpmq162.jpg "/>
#!/usr/bin/python
Import Fileinput
While True:
Name=raw_input ("Please input name:"). Strip ()
If name! = "Xiaoluo":
Print "Try Agine:"
Continue
Password=raw_input ("Please input your password:"). Strip ()
If password! = "123456":
Print "Try Agine:"
Continue
Break
While True:
Print "1.check Money"
Print "2.shopping"
Print "3.take Money"
Print "4.add Money"
Print "5.check Bill"
Print "6.exit"
Chose=raw_input ("Choose:")
If chose = = "1":
f= open ('/python/atmuser.txt ')
C=f.readlines ()
For line in C:
Print Line
If chose = = "2":
Chooping = []
Shmoney = []
Fi=file (' Shopping.txt ')
For lines in Fi.readlines ():
p = lines.split () [0]
m = Lines.split () [1]
Chooping.append (P)
Shmoney.append (M)
Print Chooping,shmoney
# buy=raw_input ("Can buy thing in this:")
Print "0. Car 20000 "
Print "1. Coffee 350 "
Print "2. Clothes 2000 "
Print "3. Bike 2500 "
Print "4. Maotai 10000 "
Buy=int (Raw_input ("You can buy thing in this:"))
F=open ('/python/atmuser.txt ')
For C in F.readlines ():
Usermoney=c.split () [1]
Print Usermoney
if int (Usermoney) > int (shmoney[buy]):
Sert=int (Usermoney)-int (Shmoney[buy])
USERMONEY=STR (SERT)
Print Usermoney
# e=open ('/python/atmuser.txt ')
# for D in E.readlines ():
# Dmoney=d.split ()
# DMONEY[1]=STR (Usermoney)
# Print Dmoney
For line in Fileinput.input ('/python/atmuser.txt ', inplace=1):
Line =line.replace (C.split () [1],usermoney)
Print line,
Else
Print "Your does has no enough money"
If chose = = "3":
Tmoney=raw_input ("Please input your Amoney of money:")
F=open ('/python/atmuser.txt ')
For C in F.readlines ():
Usermoney=c.split () [1]
if int (Usermoney) >int (Tmoney):
Sert=int (Usermoney)-int (Tmoney)
USERMONEY=STR (SERT)
For line in Fileinput.input ('/python/atmuser.txt ', inplace=1):
Line =line.replace (C.split () [1],usermoney)
Print line,
If chose = = "4":
Amoney=raw_input ("Please input add your Amoney of money:")
F=open ("/python/atmuser.txt")
For C in F.readlines ():
Usermoney=c.split () [1]
Sert=int (Usermoney) +int (Amoney)
USERMONEY=STR (SERT)
For line in Fileinput.input ('/python/atmuser.txt ', inplace=1):
Line =line.replace (C.split () [1],usermoney)
Print line,
This article is from the "Little Luo" blog, please be sure to keep this source http://xiaoluoge.blog.51cto.com/9141967/1564240
Python Learning Memo writing a credit card program