找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 3832|回复: 1

[代码与实例] 一个信用卡记账软件

1

主题

1

帖子

1

积分

贫民

积分
1
lafengyipai 发表于 2018-1-30 17:03:25 | 显示全部楼层 |阅读模式
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










回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表