import random
import math
class atm:
def __init__(self):
self.lock = []
self.list1 = []
self.hutou = {}
self.hutou1 = {}
self.hutou2 = {}
num="" #编号
name="" #姓名
id="" #身份证号
pnum="" #电话号码
password="" #密码
bnum="" #银行卡号
money=0 #存款
self.a = """ 欢迎来到银行登录系统
*************************************************
* 开户(1) 查询(2) *
* 取款(3) 存款(4) *
* 转账(5) 改密(6) *
* 锁定(7) 解锁(8) *
* 销户(9) 退出(t) *
*************************************************
"""
def go(self):
i=input("输入编号:")
if i=="1":
self.a1()
if i=="2":
self.a2()
if i=="3":
self.a3()
if i=="4":
self.a4()
if i=="5":
self.a5()
if i=="6":
self.a6()
if i=="7":
self.a7()
if i=="8":
self.a8()
if i=="9":
self.a9()
if i=="t":
self.at()
else:
print("输入错误,请重试")
self.go()
def a1(self):
j=""
self.name=input("输入姓名:")
self.id=input("输入身份证号:")
self.pnum=input("输入电话:")
while True:
self.password=input("输入密码:")
password1=input("再次输入密码:")
if password1==self.password:
self.money = int(input("请存入预存款(至少存入10元):"))
if self.money<10:
print("存款不足,已退出")
print(self.a)
self.go()
for i in range(6):
i = random.choice(range(9))
j = j + str(i)
print("您的银行卡号是:", j)
self.list1.append(j)
self.hutou[j]=self.password
self.hutou1[j]=self.money
self.hutou2[j]=self.name
print(self.a)
self.go()
else:
print("密码不匹配,请重新输入")
def a2(self):
user=input("输入要查找的账号:")
k=0
for j in self.list1:
if user==j:
atm.a7_1(self, user)
while True:
n=input("请输入密码:")
if n==self.hutou[user]:
print("密码"+self.hutou[user],"姓名:"+self.hutou2[user],"余额:"+str(self.hutou1[user]))
print(self.a)
self.go()
if n != self.hutou[user]:
k += 1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
if k==3:
print("输入次数已用尽,卡以锁死")
self.lock.append(user)
print(self.a)
self.go()
else:
print("没有此账号")
print(self.a)
self.go()
def a3(self):
user=input("输入账号:")
k = 0
for j in self.list1:
if user == j:
atm.a7_1(self, user)
while True:
n = input("请输入密码:")
if n == self.hutou[user]:
while True:
i = int(input("输入要取的款数:"))
if i > self.hutou1[user]:
print("余额不足,请重新输入:")
else:
self.hutou1[user] -= i
break
print(self.a)
self.go()
if n != self.hutou[user]:
k+=1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
if k == 3:
print("输入次数已用尽,卡以锁死")
self.lock.append(user)
print(self.a)
self.go()
if user != j:
print("没有此账号")
print(self.a)
self.go()
def a4(self):
user = input("输入账号:")
k = 0
for j in self.list1:
if user == j:
atm.a7_1(self, user)
n = input("请输入密码:")
if n == self.hutou[user]:
i = int(input("输入要存的款数:"))
self.hutou1[user] += i
print(self.a)
self.go()
if n != self.hutou[user]:
k+=1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
n=input("")
if k == 3:
print("输入次数已用尽,卡以锁死")
self.lock.append(user)
print(self.a)
self.go()
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
if user != j:
print("没有此账号")
print(self.a)
self.go()
print(self.a)
self.go()
def a5(self):
user = input("输入登陆的账号:")
k = 0
for j in self.list1:
if user == j:
atm.a7_1(self, user)
while True:
n = input("请输入密码:")
if n == self.hutou[user]:
user1 = input("输入要转的账号:")
for j1 in self.hutou.keys():
if user1 == j1:
while True:
i = int(input("输入要转的款数:"))
if i > self.hutou1[user]:
print("余额不足,请重新输入:")
else:
self.hutou1[user] -= i
self.hutou1[j1] += i
print(self.a)
self.go()
else:
print("没有此账号")
print(self.a)
self.go()
if n != self.hutou[user]:
k+=1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
if k == 3:
print("输入次数已用尽,卡以锁死")
self.lock.append(user)
print(self.a)
self.go()
break
else:
print("没有此账号")
print(self.a)
self.go()
def a6(self):
user = input("输入要更改的账号:")
k = 0
for j in self.list1:
if user == j:
atm.a7_1(self, user)
n = input("请输入密码:")
if n == self.hutou[user]:
while True:
m=input("输入要更改的密码:")
m1 = input("再次输入密码:")
if m1 == m:
self.hutou[user]=m
print("修改成功")
print(self.a)
self.go()
else:
print("两次密码不匹配,请重新输入")
if k == 3:
print("输入次数已用尽,卡以锁死")
self.lock.append(user)
print(self.a)
self.go()
if n != self.hutou[user]:
k += 1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
else:
print("没有此账号")
print(self.a)
self.go()
def a7(self):
user = input("输入要锁死的账号:")
k = 0
for j in self.list1:
if user == j:
atm.a7_1(self, user)
while True:
n = input("请输入密码:")
if n == self.hutou[user]:
print("以锁死")
self.lock.append(user)
print(self.a)
self.go()
if n != self.hutou[user]:
k += 1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
if k == 3:
print("输入次数已用尽,卡以锁死")
self.lock.append(user)
print(self.a)
self.go()
else:
print("没有此账号")
print(self.a)
self.go()
def a7_1(self,user):
for i in self.lock:
if i==user:
print("此卡以锁死")
print(self.a)
self.go()
print(self.a)
self.go()
def a8(self):
user = input("输入要解锁的账号:")
k = 0
for j in self.list1:
if user == j:
if user in self.lock:
while True:
n = input("请输入密码:")
if n == self.hutou[user]:
self.lock.remove(user)
print("卡已解锁")
print(self.a)
self.go()
if n != self.hutou[user]:
k += 1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
if k == 3:
print("输入次数已用尽,卡以锁死")
print(self.a)
self.go()
else:
print("此卡没有被锁")
print(self.a)
self.go()
else:
print("没有此账号")
print(self.a)
self.go()
def a9(self):
user = input("输入要销毁的账号:")
self.a7_1(user)
k = 0
for j in self.list1:
if user == j:
n = input("请输入密码:")
if n == self.hutou[user]:
self.list1.remove(user)
print("账号已销毁")
if n != self.hutou[user]:
k += 1
print("输入错误,请重新输入(还有%d次机会)" % (3 - k))
n = input("")
if k == 3:
print("输入次数已用尽,卡以锁死")
self.lock.append(user)
print(self.a)
self.go()
print(self.a)
self.go()
def at(self):
exit()
print(" 欢迎来到银行登录系统")
for n in range(3):
i=input("请输入用户名:")
j=input("请输入密码:")
if i=="admin" and j=="123456":
print("登陆成功")
go=True
break
else:
print("登陆失败 请重新输入")
if n==2:
print("失败已达三次,退出系统")
exit()
go=True
if go==True:
p1=atm()
print(p1.a)
p1.go()
一个愚蠢的python制作银行系统
最新推荐文章于 2024-06-02 13:37:44 发布