银行管理系统python实训报告_银行管理系统.py · HE_Xin/Python_Assignment - Gitee.com

这是一个使用Python编写的银行管理系统,包括账号认证、余额查询、存款、取款和修改密码等功能。用户信息存储在list中,通过循环和条件判断实现操作流程。

'''

银行管理系统:

登陆成功以后,会显示信息

1.查询余额

2.转账

3.修改密码

4.退出

'''

#创建一个list变量userInformation,储存着用户信息

userInformation=[

{"accountNumber":"111111","username":"张三","password":"111111","balance":10000.0},

{"accountNumber":"222222","username":"李四","password":"222222","balance":20000.0},

{"accountNumber":"333333","username":"王五","password":"333333","balance":30000.0},

{"accountNumber":"444444","username":"赵六","password":"444444","balance":40000.0}]

#账号认证函数

def accountVertification(sAccountNumber,sPassword):

global userInformation

i=0

#遍历用户信息

for user in userInformation:

#查询用户名是否存在

if sAccountNumber == user["accountNumber"]:

#检测密码是否正确

if sPassword == user["password"]:

print("您好!",userInformation[i]["username"],"!欢迎进入银行管理系统!")

return i

i += 1

else:

print("账号不存在!")

return -1

#余额查询函数

def accountBalance(userId):

global userInformation

print("您的余额为{}元!".format(userInformation[userId]["balance"]))

#存款函数

def depositMoney(userId):

while True:

#输入有效金额

money = input("请输入您的存款金额:")

#存款金额需大于零

if float(money) <=0:

print("请输入大于0的金额!")

else:

userInformation[userId]["balance"] += float(money)

print("您已存款{}元,余额为{}元!".format(money,userInformation[userId]["balance"]))

break

#取款函数

def withdrawMoney(userId):

while True:

#输入取款金额

money = input("请输入您的取款金额:")

#取款金额需大于0

if float(money) <= 0:

print("请输入大于0的金额!")

#取款金额需小于余额

elif float(money) > userInformation[userId]["balance"]:

print("您的余额不足!")

else:

userInformation[userId]["balance"] -= float(money)

print("您已取款{}元,余额为{}元,请核对金额!".format(money,userInformation[userId]["balance"]))

break

#修改密码

def changePassword(userId):

while True:

old = input("请输入旧的密码:")

if old == userInformation[userId]["password"]:

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

if old == new:

print("旧密码与新密码不能一样!")

else:

print("密码修改成功!")

userInformation[userId]["password"] = new

break

else:

print("旧密码不正确!")

#登录界面

while True:

#输入初始界面

print("="*20,"自动取款机系统","="*20)

#输入账号密码并检验

sAccountNumber = input("请输入账号:")

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

i = accountVertification(sAccountNumber,sPassword)

if i < 0:

continue

#功能选择界面

while True:

print("="*54)

print("{0:1} {1:<13} {2:<15}".format(" ","1. 查询余额","2. 存款"))

print("{0:1} {1:<13} {2:<15}".format(" ","3. 取款 ","4. 修改密码"))

print("{0:1} {1:<13}".format(" ","5. 退出系统"))

print("="*54)

key = input("请选择业务:")

if key == "1":

print("="*23,"余额查询","="*23)

accountBalance(i)

input("按任意键继续:")

elif key == "2":

print("="*25,"存款","="*25)

depositMoney(i)

input("按任意键继续:")

elif key == "3":

print("="*25,"取款","="*25)

withdrawMoney(i)

input("按任意键继续:")

elif key == "4":

print("="*23,"修改密码","="*23)

changePassword(i)

input("按任意键继续:")

elif key =="5":

print("="*25,"再见","="*25)

break

else:

print("="*23,"输入无效","="*23)

input("按任意键继续:")

break

一键复制

编辑

Web IDE

原始数据

按行查看

历史

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值