资源简介
为家里人做的一个简单的录入生成小工具,录完之后自动生成excel,附带编译好的exe文件,代码也公开,欢迎相互学习指导

代码片段和文件信息
# -*- coding: utf-8 -*-
import xlsxwriter
import time
price_all = {}
data_kind = []
data_all = {}
line_total = 0
price_filename = ‘price.txt‘
before_date_filename = ‘before_date.txt‘
with open(price_filename ‘r‘ encoding=‘UTF-8‘) as f:
for line in f:
date_temp = line.split(“:“ 1)
price_all[date_temp[0]] = int(date_temp[1])
print(price_all)
def dump_kinds():
j = 0
print(“选择种类:“)
for kind in price_all:
data_kind.append(kind)
j = j + 1
print(str(j) + “:“ + kind)
date_before = ‘‘
def write_data():
global data_all date_before
while True:
print(“--------------账单录入中-----------------“)
if date_before == ‘‘:
print(“退出请输入\‘q\‘,否则请输入时间:“)
else:
print(“退出请输入\‘q\‘,否则输入时间,如果时间和之前相同,请输入 \‘s\‘:“)
date = input()
if date == ‘q‘: break
if date == ‘‘: continue
if date == ‘s‘:
date = date_before
date_before = date
print(“-----------------------------------------------------“)
dump_kinds()
chose_num = input()
print(“-----------------------------------------------------“)
print(“输入数据:“)
input_num = input()
print(“-----------------------------------------------------“)
print(“请确认输入的数据是否准确:Y or N“)
print (“\n\n\n\n“)
print(“******************************************************“)
print(“|时间:“ + date + “ | 种类:“ + data_kind[int(chose_num) - 1] + “ | 数量:“ + input_num + “|“)
print(“******************************************************“)
print (“\n\n\n\n“)
sure_flag = input()
data_num_temp = 0
if sure_flag == ‘y‘ or sure_flag == ‘Y‘:
if date in data_all:
if chose_num in data_all[date]:
data_num_temp = data_all[date][chose_num]
data_info = {chose_num: eval(input_num) + data_num_temp}
data_all[date].update(data_info)
else:
data_all[date] = {chose_num: eval(input_num)}
else:
print (“\n“)
print(‘######################################################‘)
print(‘!!!!!WARNING:刚才的数据没有保存,请注意!!!!!‘)
print(‘######################################################‘)
print (“\n“)
print(data_all)
with open(before_date_filename ‘w‘ encoding=‘UTF-8‘) as f:
f.write(str(data_all))
f.close()
def continue_check():
try:
f = open(before_date_filename)
f.close()
except IOError:
return
while True:
print(“是否继续之前的数据进行操作?Y or N“)
continue_flag = input()
if continue_flag == ‘y‘ or continue_flag == ‘Y‘:
global data_all line_total
with open(before_date_filename ‘r‘ encoding=‘UTF-8‘) as f:
lines = f.readline
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 45 2020-05-14 11:10 python记账小工具\price.txt
文件 5316 2020-05-25 10:22 python记账小工具\scratch_1.py
文件 8956009 2020-05-25 10:26 python记账小工具\账单录入小工具V1.4.exe
目录 0 2020-07-10 11:26 python记账小工具
----------- --------- ---------- ----- ----
8961370 4
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
评论
共有 条评论