## Shero / 第一周作业 .gitee-modal { width: 500px !important; }

Explore and code with more than 6 million developers，Free private repositories ！：）
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
3.py 2.03 KB
Shero authored 2018-10-20 23:06 . Upload 3.py
print("====CSDN自动取款机====")
#账户信息
user_data = {
}
#用户界面
while True:
print('='*12, '欢迎使用ATM系统', '='*12)
print("请登录：")
user = input("请输入您的账号：")
if user in user_data:
passwd = input("请输入密码：")
while True:
print('{0:1} {1:10} {2:10}'.format(' ', '1. 余额', '2. 取钱'))
print('{0:1} {1:10} {2:10}'.format(' ', '3. 存钱', '4. 退出'))
key = input("请选择您要进行的业务：")
if key == '1':
print('您的余额为：' + str(user_data[user]['account']))
elif key == '2':
saves = input('要取多少钱：')
if int(saves) > int(user_data[user]['account']):
print("余额不足！")
else:
saves = int(user_data[user]['account']) - int(saves)
del user_data[user]['account']
user_data[user]['account'] = saves
print('取款成功，现在余额为：' + str(user_data[user]['account']))
elif key == '3':
saves = input('要存多少钱：')
saves = int(saves) + int(user_data[user]['account'])
del user_data[user]['account']
user_data[user]['account'] = saves
print('存入成功，现在余额为：' + str(user_data[user]['account']))
elif key == '4':
print('欢迎下次光临!')
break
else:
print('输入有误，请重新选择！')
else:
print('密码错误!')
else:
print('账户不存在！')