python atm银行取款系统_ATM管理系统(python)

import random

登陆界面

***********************************

* *

* 欢迎来到lyb银行,请选择服务! *

* *

***********************************

'''

display2='''

**********************

* 1.登陆 2.开户 *

* 3.查询 4.取款 *

* 5.存款 6.退出 *

* 7.转账 8.改密 *

* 9.锁卡 0.解锁 *

**********************

'''

welcome函数是整个银行系统的界面选项,提供用户进行各种操作

def welcome():

print(display)

welcome()

userdict={}

login_state = None

money =0

n = 0

while 1:

print(display2)

n =input("用户选择要操作:")

if n=='1':

login_state = login(userdict)

print(userdict)

elif n=='2':

user=register(userdict)

kanum=user.get('kanum')

userdict[kanum]=user

print('卡号为:%s'%kanum)

elif n=='3':

print(userdict)

if login_state:

refer(login_state)

else:

print("请先登陆")

elif n=='4':

if login_state:

draw(login_state)

else:

print("请先登陆")

elif n=='5':

if login_state:

fund(login_state)

else:

print("请先登陆")

elif n=='6':

login_state = None

print('退出登陆')

elif n=='7':

if login_state:

tran(login_state, userdict)

else:

print("请先登陆")

elif n=='8':

if login_state:

changepsd(login_state, userdict)

else:

print("请先登陆")

elif n=='9':

n=lock(login_state, userdict)

elif n=='0':

unlock(userdict)

else:

print("输入有误,退出系统")

break

register函数用于用户创建账户

def register(userdict):

idcard =input("身份证号:")

name = input("用户名:")

phone =input("电话号码:")

money=int(input("预存款:"))

while 1:

psd1 =input("密码:")

psd2 =input("确认密码:")

if psd1==psd2:

psd=psd2

break

else:

print("密码不一致,重新输入")

kanum=getkamun(userdict)

user ={'idcard':idcard,'name':name,'phone':phone,'money':money,'psd':psd,'kanum':kanum,'suo':False}

return user

login函数用于用户登录

def login(userdict):

usernum = input("请输入卡号:")

user =userdict.get(usernum)

if user==None:

print("卡号不存在")

return

else:

if user['suo']:

print("已锁定,请解锁后登陆")

return

for i in range(4):

psd = input("请输入密码:")

if usernum ==user.get('kanum') and psd ==user.get('psd'):

print("登陆成功")

return user.get('kanum')

else:

print("登陆失败,还有%d次机会"%i)

continue

else:

user['suo']=True

print("登陆次数超过三次,已锁定")

fund函数用于用户存款

def fund(kanum):

user = userdict.get(kanum)

money=user['money']

money += eval(input("输入金额"))

user['money']=money

print("成功!当前余额为%d" % money)

return None

refer函数用于用户查询当前余额

def refer(kanum):

user = userdict.get(kanum)

money = user['money']

print("当前余额为%d"%money)

return None

draw函数用于用户取款

def draw(kanum):

user = userdict.get(kanum)

money=user['money']

while 1:

money -= eval(input("输入金额"))

if money>=0:

user['money']=money

print("成功!当前余额为%d"%money)

break

else:

print("输入大于余额,重新输入")

break

return None

tran函数用于用户转账操作

def tran(kanum,userdict):

user = userdict[kanum]

print(user)

obj = input("请输入卡号:")

if obj not in userdict:

print("卡号不存在")

else:

money2 = int(input("请输入转账金额:"))

if money2

user['money'] -= money2

userdict.get(obj)['money'] +=money2`

print("转账成功,余额为%d"%user['money'])

return

else:

print("余额不足")

changepsd函数用于用户修改密码

def changepsd(kanum,userdict):

user = userdict[kanum]

oldpsd = input("请输入当前密码:")

if oldpsd == user['psd']:

newpsd = input("请输入新密码:")

user['psd'] = newpsd

print("修改成功")

else:

print("密码错误")

lock函数用于用户锁卡操作

def lock(kanum,userdict):

kanum = input("请输入您的卡号:")

if kanum in userdict:

idcard = input("请输入身份证号码:")

name = input("请输入姓名:")

phone = input("请输入电话:")

user = userdict[kanum]

if idcard==user['idcard'] and name==user['name'] and phone==user['phone']:

user['suo']=True

print("锁定成功")

return

else:

print("信息有误")

else:

print("卡号不存在")

return

nulock函数用于用户解锁银行卡

def unlock(userdict):

kanum = input("请输入卡号:")

if kanum in userdict:

idcard = input("请输入身份证:")

name = input("请输入姓名:")

phone = input("请输入电话:")

user = userdict[kanum]

if idcard==user['idcard'] and name==user['name'] and phone==user['phone']:

user['suo']=False

print("解锁成功")

return

else:

print("信息有误")

else:

print("卡号不存在")

return

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值