python核心编程第九章(9-10)
来源:互联网 发布:单片机 液晶屏与电机 编辑:程序博客网 时间:2024/05/23 15:56
import ConfigParser
def financial():
"""9–10. 家庭理财.创建一个家庭理财程序. 你的程序需
要处理储蓄, 支票, 金融市场, 定期存款等多种帐户.为每
种帐户提供一个菜单操作界面, 要有存款, 取款, 借,贷等
操作. 另外还要提供一个取消操作选项. 用户退出这个程序
时相关数据应该保存到文件里去(出于备份的目的,程序执行
过程中也要备份.)"""
prompt ='''
(S)avings
(C)heck
(F)inancial market
(D)eposit
(E)xit
Enter your selection:'''
function ='''
(s)avings
(d)raw
(b)orrow
(l)oan
Enter your selection:'''
account = {'s':'Savings','c':'Check','f':'Financial','d':'Deposit'}
fun = {'s':'savings','d':'draw','l':'loan','b':'borrow'}
cf = ConfigParser.ConfigParser()
cf.read('FamilyAccount.ini')
enter = raw_input(prompt).strip()[0].lower()
while True:
if enter in 'scfd':
print 'Welcome %s business!' %account[enter].lower()
section = account[enter]
select = raw_input(function).strip()[0].lower()
if select in 'sdbl':
print 'Welcome %s business!' %fun[select]
key = fun[select]
monkey = int(raw_input\
('Enter amount of money <must be digit.>:').strip())
cf.set(section,key,monkey)
cancel = raw_input('Cancel,please press "c" ...\n')
if cancel == 'c': return False
else:
fp = open('FamilyAccount.ini','w')
cf.write(fp)
fp.close()
elif enter == 'e':return False
else: print 'Invalid operation,try again!'
def financial():
"""9–10. 家庭理财.创建一个家庭理财程序. 你的程序需
要处理储蓄, 支票, 金融市场, 定期存款等多种帐户.为每
种帐户提供一个菜单操作界面, 要有存款, 取款, 借,贷等
操作. 另外还要提供一个取消操作选项. 用户退出这个程序
时相关数据应该保存到文件里去(出于备份的目的,程序执行
过程中也要备份.)"""
prompt ='''
(S)avings
(C)heck
(F)inancial market
(D)eposit
(E)xit
Enter your selection:'''
function ='''
(s)avings
(d)raw
(b)orrow
(l)oan
Enter your selection:'''
account = {'s':'Savings','c':'Check','f':'Financial','d':'Deposit'}
fun = {'s':'savings','d':'draw','l':'loan','b':'borrow'}
cf = ConfigParser.ConfigParser()
cf.read('FamilyAccount.ini')
enter = raw_input(prompt).strip()[0].lower()
while True:
if enter in 'scfd':
print 'Welcome %s business!' %account[enter].lower()
section = account[enter]
select = raw_input(function).strip()[0].lower()
if select in 'sdbl':
print 'Welcome %s business!' %fun[select]
key = fun[select]
monkey = int(raw_input\
('Enter amount of money <must be digit.>:').strip())
cf.set(section,key,monkey)
cancel = raw_input('Cancel,please press "c" ...\n')
if cancel == 'c': return False
else:
fp = open('FamilyAccount.ini','w')
cf.write(fp)
fp.close()
elif enter == 'e':return False
else: print 'Invalid operation,try again!'
0 0
- python核心编程第九章(9-10)
- python核心编程第九章(9-11)
- python核心编程第九章(9-12)
- Python核心编程 第九章
- 《Python核心编程》第九章
- python 核心编程 第九章
- Python核心编程第九章笔记
- python核心编程--第九章 9.11 练习
- python核心编程第九章答案
- Python核心编程 第九章练习
- python核心编程第九章练习
- python 核心编程第九章练习题
- 《Python核心编程》第九章编程题代码
- python核心编程第九章习题答案(1)
- python核心编程第九章习题答案(2)
- python核心编程第九章习题答案(3)
- python核心编程第九章_文件系统的一个程序
- 《Python核心编程》第九章:文件和输入输出
- python核心编程第九章(9-11)
- Ubuntu下SSH设置
- storyboard的问题
- Linux中查看CPU信息
- last day on windows programming
- python核心编程第九章(9-10)
- highcharts特殊定制:x轴文字竖直显示(兼容各浏览器)
- 远程备份还原SQL数据库
- RabbitMQ学习之集群部署
- UVA - 757 Gone Fishing 贪心+枚举
- web服务层不需要外键
- 程序员也文艺:海燕——高尔基
- 第九章 内联函数
- zoj 3430 Detect the Virus(AC自动机)