# 创建一个账号密码
Account = [{'Name': 'admin', 'Password': '123', 'Balance': 3000}]
# 定义主界面函数
def wpc():
print("*" * 50)
print("*" + " " * 48 + "*")
print("*" + " 欢迎光临,花旗银行自助终端为您服务! " + "*")
print("*" + " " * 48 + "*")
print("*" * 50)
print("1.登陆账号" "2.退出系统")
# 创建用户登陆功能界面函数
def option_wpc():
print("*" * 50)
print("*" + " " * 48 + "*")
print("*" + " 欢迎光临,花旗银行自助终端为您服务! " + "*")
print("*" + " " * 48 + "*")
print("*" * 50)
print(' ' * 30 + '*' + '您好 %s' % Account[i]['Name'] + '*' + ' ' * 30)
print('''
1.存款 2.取款
3.查询 4.退出
''')
print('=' * 20 + '花旗银行自助终端为您服务' + '=' * 20)
def judge1():
while 1:
wpc()
judge_1 = input('请选择您需要的服务:')
if judge_1 == '1':
user_login() # 执行用户的登陆
elif judge_1 == '2':
print('感谢您对本银行的使用,欢迎再次光临!')
input('>>按任意键退出银行服务<<')
exit()
else:
print('请输入功能数字!')
input('>>按确定键继续为您服务<<')
# 定义一个功能界面判断函数
def judge2():
while 1:
option_wpc() # 进入功能界面
judge_2 = input('请选择您需要进行的银行的服务:')
if judge_2 == '3':
print('您的账号余额为:%0.2f' % Account[i]['Balance'])
elif judge_2 == '2':
a = int(input('请输入你的取款金额:'))
if Account[i]['Balance'] - a >= 0: # 判断余额是否足够
balance = Account[i]['Balance'] - a
dict1 = {'Balance': balance}
Account[i].update(dict1) # 更新账户余额
print('取款成功,取款金额为:%d,账户余额为:%d' % (a, balance))
else:
print('您的账号余额不足!')
input('>>按确定键继续为您服务<<')
elif judge_2 == '1':
a = int(input('请输入你的存款金额:'))
total = a + Account[i]['Balance']
dict2 = {'Balance': total}
Account[i].update(dict2) # 更新存款金额
print('恭喜您存款成功,您的存款金额为:%d,账户余额为:%d' % (a, total))
elif judge_2 == '4':
print('感谢您的使用,欢迎再次光临!')
exit()
else:
print('对不起,请输入选项中的数字功能!')
def user_login():
k = 3 # 定义允许用户输入错误的次数不能超过三次
while k:
global i # 定义一个全局变量
username = input('请输入您的用户名:')
password = input('请输入您的密码密码:')
for i in range(len(Account)):
if username in a_username and password in b_password: # 遍历出来的用户名和密码在列表中,执行
if username == Account[i]['Name']:
if password == Account[i]['Password']: # 用户名和密码匹配一致,执行
judge2() # 进入功能界面判断
break
else: # 用户名和密码不匹配,执行
print('用户名和密码错误,请重新输入!')
# break
elif username not in a_username or password not in b_password: # 用户名或密码不在列表中,执行
k -= 1
if k == 1:
print('对不起,您输入的用户名或密码输入错误已达2次,还有一次机会,请小心输入')
break
elif k == 0:
print('您的银行卡已被吞,请联系银行客服电话95599!')
judge1()
print('用户名或密码输入错误,请重新输入!')
break
# 主运行函数
while 1:
judge1()
相似问题