银行账号资金交易管理 —— 完整版
简介:
步骤:
- 初始化余额
- 初始化交易日志
- 初始化函数
- 设置表格头
- 区分存款和取款
- 添加到日志列表
代码:
import time
import prettytable as pt
balance = 1000 # 初始化余额
acount_log = [] # 初始化交易日志
class Bank:
def __init__(self):
"""初始化"""
global balance
self.balance = balance
self.acount_log = acount_log
def deposit(self):
"""存款"""
amount = float(input('请输入存款金额:'))
self.balance += amount
self.write_log(amount,