|
import xlwt;
import xlrd;
from xlutils.copy import copy;
import os
import easygui as g
g.msgbox("=================================拉风的记账本=================================",image='G:\\python\\我的第一个程序\\11.gif',title="拉风记账本", ok_button="开始记账")
def write_sheet():
time=g.enterbox("请输入日期:")
credit_card=g.enterbox("请输入哪个信用卡:")
consume=g.enterbox("请输入消费金额:")
wb1=xlrd.open_workbook('C:\\Users\\Administrator\\Desktop\\记账本.xls',formatting_info=True)
charge_up=wb1.sheet_by_index(0)
charge_up1=copy(wb1);
charge_up2=charge_up1.get_sheet(0);
nrows=charge_up.nrows#获取行号?
charge_up2.write(nrows,0,time)
charge_up2.write(nrows,1,credit_card)
charge_up2.write(nrows,2,consume)
charge_up1.save('C:\\Users\\Administrator\\Desktop\\记账本.xls')
if os.path.exists('C:\\Users\\Administrator\\Desktop\\记账本.xls'):
write_sheet()
count=1
while count<2:
if g.ccbox('还有继续记录吗?',choices=('要啊要啊^_^', '算了吧T_T')):
write_sheet()
else:
break
else:
wb=xlwt.Workbook()
wb_sheet=wb.add_sheet('记账本')
wb_sheet.write(0,0,'日期')
wb_sheet.write(0,1,'信用卡')
wb_sheet.write(0,2,'消费金额')
wb.save('C:\\Users\\Administrator\\Desktop\\记账本.xls')
write_sheet()
count=1
while count<2:
if g.ccbox('还有继续记录吗?',choices=('要啊要啊^_^', '算了吧T_T')):
write_sheet()
else:
break
|
|