netAmount = 0
while True:
print("请输入:")
s = input()
if not s:
break
values = s.split(" ")
print(values)
operation = values[0]
print(operation)
amount = int(values[1])
print(amount)
if operation=="D":
netAmount+=amount
elif operation=="W":
netAmount-=amount
else:
pass
print(operation)
print(amount)
print(netAmount)
print (netAmount)
事务日志格式如下所示:
D 100
W 200
D表示存款,而W表示提款。
结果: