以口袋记账做茄为例,首先这款APP的设计风格小编非常的喜欢,如果你想知道钱花在哪儿了,想存钱却总也存不下镇圆来钱,那这款APP一定要试一试,它能够让你清晰纯旅察的知道自己钱款的去向。
生意如何进销存就是一款专门管理生意账桐简的手机进销存记账软件,几乎适用于所有行业, *** 局雀裤作也很简单易上手,不需要你有专业的财务知识,每天抽空拿出手机记下账即可,不用再投资电脑节省开支,支持多人、多店铺、多岁盯仓库管理,可以设置人员权限,你可以安装个试试。import pickle
import time
import os
def cost(fname):
'用于记录花费'
cost_time = time.strftime('启敏%Y-%m-%d')
try:#异常处理机制
cost_deposit = int(input('花销金额:'))
cost_mark = input('花销说明:')
except ValueError:
print('无效的金额')
return # 函数的return类似于循环的break,return提前结束函数。
except (KeyboardInterrupt, EOFError):
print('\nbye-bye')
exit(1)
# 在文件中取出所有的收支记录
with open(fname,'rb') as fobj:
records = pickle.load(fobj)
# 计算最新余额
balance = records[-1][-2] - cost_deposit
# 构建最新一笔收入
record = [cost_time,0,cost_deposit,balance,cost_mark]
# 将收入追加到收支列表中
records.append(record)
# 将最新收支情况写入文件
with open(fname,'wb') as fobj:
pickle.dump(records,fobj)
def save(fname):
save_time = time.strftime('%Y-%m-%d')
try:
save_deposit = int(input('收入金额:'))
save_mark = input('收入说明:')
except ValueError:
print('无效的金额')
return
except (KeyboardInterrupt,EOFError):
print('bye-bye')
exit(1)
with open(fname, 'rb') as fobj:
records = pickle.load(fobj)
balance = records[-1][-2] + save_deposit
record = [save_time,save_deposit,0,balance, save_mark]
records.append(record)
with open(fname, 'wb') as fobj:
pickle.dump(records, fobj)
def query(fname):
'用于查账'
# 打印表头
print(f'{"date":<15}{"save":<8}{"cost":<8}{"悄贺枝balance":<12}{"mark":<50}')
with open(fname,'rb') as fobj:
records = pickle.load(fobj)
for date,cost,save,balance,mark in records:
print(f'{date:<15}{cost:<8}{save:<8}{balance:<12}{mark:<50}')
def menu():
funcs = {'0':cost,'拍毕1':save,'2':query}
prompt = '''(0)开销
(1)收入
(2)查询
(3)退出
请选择(0/1/2/3):'''
fname = 'account.data'
if not os.path.exists(fname):
init_data = [[time.strftime('%Y-%m-%d'),0,0,10000,'init_data']]
with open(fname,'wb') as fobj:
pickle.dump(init_data,fobj)
while 1:
try:
choice = input(prompt).strip()
except(KeyboardInterrupt,EOFError):
choice = '3'
if choice not in ['0','1','2','3']:
print('无效输入,重试')
continue
if choice == '3':
print('\nbye_bye')
break
funcs[choice](fname)
if __name__ == '__main__':
menu()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)