初衷
看了《奇特的人生》后想试试里边柳比歇夫的办法记录下时间,看看能不能多把握点时间的下脚料
文本
我的文本使用子弹短信记录的,然后把再拷贝到电脑上。格式是:
[事项] [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()