需求:
1、自动控测电脑有没有注册账号
2、注册账号功能
3、登陆账户三次失败,锁定账户,并禁止登陆(每次登陆失败提示还有几次机会)
4、修改密码功能(第一次先输入旧密码,后两次输入相同的新密码,否则报错提示)
5、可以取款,提现、转账,一次性取款存款转账限额一万五 (开发一半)
6、存款手续费3%,提现手续费5% (未开发)
7、可以预透支金额,限额三万 (还剩一半功能)
8、每月10号为还款日,过期未还,按欠款额5%利息(未开发)
9、还款功能(包括查看欠款金额、还款、还剩计息日) (开发一半)
10、查看个人账户信息(如:用户名、性别、职业、余额) (未开发)
11、查看近三十天账号操作记录(包括登陆次数、取款、存款、转账和操作的时间) (未开发)
12、登陆需要输入验证码 (未开发)
#所有模块展示
#主程序
cat __init__.py #!/usr/bin/env python #coding: utf-8 import login_verify import select_menu import modify_passwd import Operating_funds import check_account import sys if __name__ == ‘__main__‘: check_account.zc() login_verify.login_account() while True: select_menu.menu_options() service = int(raw_input(‘请选择服务类型:‘)) if service == 1: modify_passwd.change_passwd() elif service == 2: Operating_funds.rmb_operation() elif service == 5: print ‘Bye‘ sys.exit() else: print ‘你输入的选项不存在,请重新输入‘ print
#自动探测账号和注册账号模块
cat check_account.py #!/usr/bin/env Python #coding:utf-8 account_file = ‘f:/accounts_file.txt‘ def zc(): try: f=open(account_file) except: print ‘检测到你的电脑还没有注册账号,请先注册账号再使用柜员机系统,感谢你对本系统的支持!‘ while True: try: zh=raw_input(‘请输入你要注册的账号(必须是纯数字,长度为3位):‘) a=int(zh) except: print ‘抱歉,你只能输入数字‘ else: lenzh=len(zh) if lenzh!= 3: print ‘你输入的账号长度不对,请重新输入‘ else: break while True: try: mm1=raw_input(‘请输入你要设置的密码,必须是纯数字,长度为六位:‘) mm2=raw_input(‘请再次输入你要设置的,必须是纯数字,长度为六位:‘) a=int(mm1) a=int(mm2) except: print ‘抱歉,你只能输入数字‘ else: lenmm1=len(mm1) lenmm2=len(mm2) if lenmm1 != 6 and lenmm2 != 6: print ‘你输入的账号长度不对,请重新输入‘ else: if mm1 != mm2: print ‘你两次输入的新密码不匹配,请重新输入‘ else: with open(account_file,‘a‘) as f: f.write(zh + ‘\t‘) f.write(mm2 +‘\n‘) with open(‘f:/‘ + zh + ‘_ye.txt‘,‘w‘) as f: f.write(‘0‘) print ‘恭喜你账号注册成功 ‘ break else: f.close()
#登陆账号脚本
cat login_verify.py #!/usr/bin/env Python #coding:utf-8 def login_account(): #导入需要用的模块 import time import sys #定义循环次数变量 last_count = 3 login_count = 3 LoginError_conunt = 0 #定义账户文件变量 accounts_file = ‘f:/accounts_file.txt‘ accounts_lock = ‘f:/accounts_lock.txt‘ login_file = ‘f:/login_file.txt‘ #三次输入正确密码的机会 while LoginError_conunt < login_count: #输入账号 username = raw_input(‘请输入你的账号:‘) #登陆账号已所告警 with open(accounts_lock) as f: for line in f.readlines(): user = line.strip(‘\n‘) if username == user: print "对不起,你的账户已锁定,无法登陆" sys.exit() #输入密码 password = raw_input(‘请输入你的密码:‘) #账号密码输入成功 with open(accounts_file) as f: Match_flag = False for line in f.readlines(): user,passwd = line.strip(‘\n‘).split() if username == user and password == passwd: print ‘正在登陆,请稍候‘, for i in xrange(5): # @UnusedVariable time.sleep(1) print ‘.‘, print print "login success..." print "Welcome %s login Teller system" % user with open(login_file,‘w‘) as f: f.write(username+‘\t‘) f.write(password) Match_flag = True time.sleep(1) print #输错密码告警 if Match_flag == False: last_count -= 1 LoginError_conunt += 1 print "你输入账号或密码不正确,请重新输入" print ‘你还有%s次机会‘ % last_count else: break else: #三次输入密码机会用完锁账号 print "Your account is locked " f=file(accounts_lock,‘ab‘) f.write(username+‘\n‘) f.close() sys.exit()
#选择菜单模块
#select_menu.py def menu_options(): li = [ ‘ 1、修改密码‘, ‘ 2、资金操作‘, ‘ 3、查看个人账号信息‘, ‘ 4、查看操作记录‘, ‘ 5、退出‘ ] #for list in enumerate(li,1): for list in li: print list print
#更改密码模块
cat modify_passwd.py #!/usr/bin/env Python #coding:utf-8 def change_passwd(): #导入常用模块 import os import sys #旧密码本次新循环变量 last_count = 3 Change_count = 3 ChangeError_conunt = 0 #新密码三次循环变量 last_new_count = 3 Change_new_count = 3 ChangeError_new_conunt = 0 #账户文件变量 accounts_file = ‘f:/accounts_file.txt‘ login_file = ‘f:/login_file.txt‘ new_accounts_file = ‘f:/new_accounts_file.txt‘ accounts_lock = ‘f:/accounts_lock.txt‘ #三次输入正确旧密码机会 while ChangeError_conunt < Change_count: old_passwd = raw_input(‘请输入你的旧密码:‘) Match_flag = False with open(login_file) as f: for li in f.readlines(): username,password=li.split() if old_passwd == password: Match_flag = True #三次输入正确新密码机会 while ChangeError_new_conunt < last_new_count: new1_passwd = raw_input(‘请输入你的新密码:‘) new2_passwd = raw_input(‘请再次输入你的新密码:‘) if new1_passwd == new2_passwd: last_count = 3 ChangeError_conunt = 0 with open(accounts_file) as f: for line in f.readlines(): new_file = file(new_accounts_file,‘ab‘) new_file.write(line.replace(password,new2_passwd)) new_file.close() os.remove(accounts_file) os.rename(new_accounts_file, accounts_file) with open(login_file,‘w‘) as f: f.write(username+‘\t‘) f.write(new2_passwd) print ‘passwd: 所有的身份验证令牌已经成功更新。‘ break else: #新密码输错警告信息输出 last_new_count -= 1 ChangeError_new_conunt += 1 print "抱歉,两次输入的新密码不匹配:" print ‘你还有%s次机会‘ % last_new_count if last_count == 0: print "passwd: 已经超出服务重试的最多次数" sys.exit() #旧密码输错警告信息输出 if Match_flag == False: last_count -= 1 ChangeError_conunt += 1 print "你输入的旧密码有误,请重新输入:" print ‘你还有%s次机会‘ % last_count else: break else: #三次输入旧密码机会用完锁账号 print "你输入的次数过多,账号已锁定" f=file(accounts_lock,‘ab‘) f.write(username+‘\n‘) f.close()
#资金操作模块
cat Operating_funds.py #!/usr/bin/env Python #coding:utf-8 def rmb_operation(): while True: zijin="f:/ye.txt" dk=‘f:/dk.txt‘ yb = 100 sb = 300 wb = 500 yq = 1000 lq = 2000 print ‘‘‘ 1、查看余额 2、存款 3、提现 4、贷款 5、还款 6、转账 7、返回首页 ‘‘‘ xuan1 = input(‘请选择你要执行的操作:‘) def menu(): print ‘‘‘ 1、100元 2、300元 3、500元 4、1000元 5、2000元 6、手动输入其它金额 7、返回上一页 ‘‘‘ def dk_menu(): print ‘‘‘ 1、查看已贷款资金 2、手动输入贷款金额 3、返回上一页 ‘‘‘ def xye(): with open(zijin,‘wb‘) as f: f.write(ye) print ‘存款完成,你现在的余额为%s元‘ % ye if xuan1 == 1: with open(zijin) as f: ye=int(f.readline()) print ‘你的账户余额为%d元‘ % ye elif xuan1 == 2: while True: menu() chun = input(‘请选择你要存款的额度:‘) with open(zijin) as f: ye = int(f.readline()) if chun == 1: ye = ye + yb elif chun == 2: ye = ye + sb elif chun == 3: ye = ye + wb elif chun == 4: ye = ye + yq elif chun == 5: ye = ye + lq elif chun == 6: sczj = input(‘请输入你要存款的金额:‘) ye = ye + sczj else: break ye=str(ye) xye() elif xuan1 == 3: while True: menu() chun = input(‘请选择你要存款的额度:‘) with open(zijin) as f: ye = int(f.readline()) if chun == 1: ye = ye - yb elif chun == 2: ye = ye - sb elif chun == 3: ye = ye - wb elif chun == 4: ye = ye - yq elif chun == 5: ye = ye - lq elif chun == 6: sczj = input(‘请输入你要存款的金额:‘) ye = ye - sczj else: break ye=str(ye) xye() elif xuan1 == 4: while True: dk_menu() dai = input(‘请选择选项:‘) if dai == 1: try: f = open(dk) except: with open(dk) as f: f.write(‘0‘) print ‘你现在的余额为0元‘ else: f.close() with open(dk) as f: f = f.readline() print ‘你现在的余额为%s元‘ % f if dai == 2: daikuan = input(‘请选择你要贷款的额度:‘) try: f=open(dk) except: with open(dk,‘w‘) as f: f=f.write(daikuan) print ‘你现在的余额为%s元‘ % f else: f.close() with open(dk) as f: dlk = int(f.readline()) dlk = dlk + daikuan dlk = str(dlk) with open(dk,‘wb‘) as f: f.write(dlk) print ‘你现在的余额为%s元‘ % dlk else: break elif xuan1 == 7: break rmb_operation() #‘‘‘ #def Check your balance(): #查看余额 #def Withdrawals(): #取款 #‘‘‘ # print ‘‘‘ #‘‘‘ # qu=int(raw_input(‘请选择编号提现:‘)) # if qu == 1: # elif qu == 2: #elif qu == 3: # elif qu == 4: #elif qu == 5: #elif qu == 6: #Withdrawals() #def Transfers(): #转账 #def Repayment(): #还款
未完、待续...
本文出自 “wsyht90的博客” 博客,请务必保留此出处http://wsyht90.blog.51cto.com/9014030/1829422
原文地址:http://wsyht90.blog.51cto.com/9014030/1829422