python银⾏管理系统(运⽤了⽂件操作)
系统要能实现⼀下功能:
开户功能:根据⽤户输⼊的姓名,⾝份证号,电话号,预存⾦额,密码等信息,若⽆误后,就会获得系统随机⽣成⼀个不重复的由6位数字组成的银⾏账号。
查询功能:如果⽤户的账号和密码输⼊正确,就可以查询⾃⼰卡内的⾦额。
取款功能:如果⽤户的账号和密码输⼊正确的前提下,可以取出卡内的⾦额,若取出的⾦额⼤于卡内的⾦额,则会终⽌此次交易,并会提⽰银⾏卡内余额不⾜。若卡内⾦额⼤于等于要取款的⾦额,则可以正常取款。
存款功能:如果⽤户的账号和密码输⼊正确的前提下,可以存⼊到卡内的⾦额中,若存款的⾦额⼩于0,则会终⽌此次交易,并会提⽰银⾏存款⾦额不对。
转账功能:如果⽤户的账号和密码输⼊正确的前提下,可以向已经在本⾏中注册⽣成的其他账号进⾏转账服务(只需要知道转账对象的卡号)。若输⼊的卡号未在本⾏中注册过,则会终⽌此次交易。
锁定功能:银⾏管理员可以对信誉度不好的⽤户进⾏账号锁定,锁定的账号不能进⾏存款,取款,查询,转账功能。
解锁功能:银⾏管理员可以对账号锁定的⽤户进⾏解锁操作,解锁后的账号恢复存款,取款,查询,转账功能。
import random
class bank():
def kaihu(self):#开户
name = input("请输⼊您的姓名:")
nid = input("请输⼊您的⾝份证号码:")
tel = input("请输⼊您的电话号码:")
yc = float(input("请输⼊您预存⾦额:"))
users = random.randint(100000,999999)
flag = True
while flag:
ist(str(users)) is True:
users = random.randint(100000,999999)
ist(str(users)) is False:
flag =False
bank = str(users) + "-" + password + "-" + name + "-" + nid + "-" + tel + "-" + str(yc) + "-" +"True"+"\n" with open("","a+") as file:
file.write(bank)
diayc[users] = yc
dia[users] = password
print(users)
print("开户成功!")
def select(self):#查询
users = int(input("请输⼊您的账号:"))
password = input("请输⼊您的密码:")
with open("","r") as f:
lines = f.readlines()
for line in lines:
users1 = line.split("-")[0]
password1 = line.split("-")[1]
if line.split("-")[6] == "True\n":
if password == password1 and str(users) == users1:
yuan = line.split("-")[5]
print("您的⾦额为:"+yuan)
else:
print("账号已被锁定!⽆法进⾏查询")
def qukuan(self):#取款
users = int(input("请输⼊您的账号:"))
password = input("请输⼊您的密码:")
with open("","r") as f:
lines = f.readlines()
for line in lines:
password1 = line.split("-")[1]
users1 = line.split("-")[0]
if line.split("-")[6] == "True\n":
if password == password1 and str(users) == users1:
yuan = float(line.split("-")[5])
print("您的⾦额为:"+str(yuan))
i = float(input("输⼊您要取款⾦额:"))
yuan = yuan - i
if yuan >= 0:
print("取款成功")
else:
print("卡内余额不⾜")
break
with open("","r") as f:
grow = f.readlines()
with open("","w+") as f1:
if str(users) in i:
name=line.split("-")[2]
nid = line.split("-")[3]
tel = line.split("-")[4]
bank = str(users) + "-" + password + "-" + name + "-" + nid + "-" + tel + "-" + str(yuan) + "-" +"True"+"\n"
f1.write(bank)
continue
f1.write(i)
else:
print("账号已被锁定!⽆法进⾏取款")
def cunkuan(self):#存款
while count<3:
users = int(input("请输⼊您的账号:"))
password = input("请输⼊您的密码:")
writelines在python中的用法with open("","r") as f:
lines = f.readlines()
for line in lines:
password1 = line.split("-")[1]
users1 = line.split("-")[0]
if line.split("-")[6] == "True\n":
if password == password1 and str(users) == users1:
yuan = float(line.split("-")[5])
print("您的⾦额为:"+str(yuan))
i = float(input("输⼊您要存款⾦额:"))
yuan = yuan + i
if i >= 0:
print("存款成功")
else:
print("存款⾦额输⼊有误")
break
with open("","r") as f:
grow = f.readlines()
with open("","w+") as f1:
for i in grow:
if str(users) in i:
name=line.split("-")[2]
nid = line.split("-")[3]
tel = line.split("-")[4]
bank = str(users) + "-" + password + "-" + name + "-" + nid + "-" + tel + "-" + str(yuan) + "-" +"True" +"\n"
f1.write(bank)
continue
f1.write(i)
else:
print("账号已被锁定!⽆法进⾏存款")
def zhuanzhang(self):
users = int(input("请输⼊您的账号:"))
password = input("请输⼊您的密码:")
with open("","r") as f:
lines = f.readlines()
for line in lines:
if line.split("-")[6] == "True\n":
if password == password1 and str(users) == users1:
yuan = float(line.split("-")[5])
print("您的⾦额为:"+str(yuan))
b = int(input('请输⼊您要转账的银⾏卡号:'))
ist(str(b)) is False:
print("该账号不存在!")
break
j = float(input("输⼊您要转账⾦额:"))
yuan = yuan - j
if yuan < 0:
print("卡内余额不⾜")
break
with open("","w+") as f1:
for i in lines:
if str(users) == i.split("-")[0]:
name= i.split("-")[2]
nid = i.split("-")[3]
tel = i.split("-")[4]
bank = str(users) + "-" + password + "-" + name + "-" + nid + "-" + tel + "-" + str(yuan) + "-" + "True" + "\n"
f1.writelines(bank)
continue
if str(b) == i.split("-")[0]:
password1 = i.split("-")[1]
name1= i.split("-")[2]
nid1 = i.split("-")[3]
tel1 = i.split("-")[4]
qian = i.split("-")[5]
total = float(qian) + j
bank1 = str(b) + "-" + password1 + "-" + name1 + "-" + nid1 + "-" + tel1 + "-" + str(total)+ "-" + "True" + "\n"
f1.writelines(bank1)
continue
f1.write(i)
print("已完成此次交易")
else:
print("账号已被锁定!⽆法进⾏转账")
def suoding(self):#锁定
users = int(input("请输⼊要锁定的账号:"))
flag = True
while flag:
ist(str(users)) is True:
flag = False
ist(str(users)) is False:#判断账号是否存在
users = int(input("账号不存在,请重新输⼊要锁定的账号:"))
with open("","r") as f:
lines = f.readlines()
with open("","w+") as f1:
for line in lines:
if str(users) == line.split("-")[0]:
password1 = line.split("-")[1]
tel1 = line.split("-")[4]
qian = line.split("-")[5]
t = "False\n"
bank2 = str(users) + "-" + password1 + "-" + name1 + "-" + nid1 + "-" + tel1 + "-" + qian+ "-" + t f1.writelines(bank2)
continue
f1.write(line)
print("此账号已被封锁")
def jiesuo(self):
users = int(input("请输⼊要解锁的账号:"))
flag = True
while flag:
ist(str(users)) is True:
flag = False
ist(str(users)) is False:#判断账号是否存在
users = int(input("账号不存在,请重新输⼊要解锁的账号:"))
with open("","r") as f:
lines = f.readlines()
with open("","w+") as f1:
for line in lines:
if str(users) == line.split("-")[0]:
password1 = line.split("-")[1]
name1= line.split("-")[2]
nid1 = line.split("-")[3]
tel1 = line.split("-")[4]
qian = line.split("-")[5]
t = "True\n"
bank2 = str(users) + "-" + password1 + "-" + name1 + "-" + nid1 + "-" + tel1 + "-" + qian+ "-" + t f1.writelines(bank2)
continue
f1.write(line)
print("此账号已被解锁")
@staticmethod
def exist(users):#判断账号是否重复及存在
flag = False
with open("","r") as f:
lines = f.readlines()
for line in lines:
if users in line:
flag = True
break
return flag
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论