python日常时间记录

用pyecharts库简单记录时间

初衷

看了《奇特的人生》后想试试里边柳比歇夫的办法记录下时间,看看能不能多把握点时间的下脚料

文本

我的文本使用子弹短信记录的,然后把再拷贝到电脑上。格式是:

[事项] [num]分钟
如:奇葩说 120分钟

程序

# coding=gbk
from pyecharts import Pie
def build_lists(a):
    dicall = {}
    tings = []
    spend = []
    num = len(a)
    for i in range(num):
        if a[i][0].isnumeric() == False:
            tings.append(a[i])
            spend.append(int(a[i+1]))
            if a[i] in dicall:
                dicall[a[i]] += int(a[i+1])
            else:dicall[a[i]] = int(a[i+1])
        else:continue
    return dicall

def build_pid(dicall):
    tings = []
    spend = []
    for key,value in dicall.items():
        tings.append(key)
        spend.append(value)
    pie = Pie(" ")
    pie.add("饼图",tings,spend,legend_orient="vertical",legend_pos="left",center=[75, 50])
    pie.render(r'C:\Users\asshole\Desktop\pie.html') #Output the chart to desktop

fr = open(r'C:\Users\asshole\Desktop\record.txt','r') #My time recording text's location.
a = fr.read().replace("\n"," ").replace("分钟",'').split(" ")
dicall = build_lists(a)
build_pid(dicall)

fr.close()


效果

鼠标放在色块上会显示占比和事项

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值