正文之前
上午给爸爸打了个电话庆祝他50岁生日,在此之前搞了个大扫除,看了会知乎,到实验室已经十一点多了。约喜欢的妹子吃饭失败,以至于工作积极性收到了打击,所以就写个程序来统计下开学十一天的财务消费情况,更清楚的认识自己。
Python资源共享群:626017123
正文
废话不多说,先放代码:
import matplotlib.pyplot as plt import matplotlib from pylab import mpl plt.rcParams['font.sans-serif']=['SimHei'] def getAll(x): s=0 for i in x: s+=i return s sump = [374.9,70,85.5,72.9,33.7,14.8,35.4,30.1,66.52,114.3,-13] fruit = [0,0,0,10,0,0,0,0,35,0,0] other = [338.6,50,53.8,49.5,10,0,0,0,6.42,92,-34] food = [] for i in range(len(sump)): food.append(sump[i] - fruit[i] - other[i]) date = [] for i in range(11): date.append("8."+str(i+14)) plt.xlabel(u"时间") plt.ylabel(u"消费") plt.plot(date,sump) plt.plot(date,fruit) plt.plot(date,other) plt.plot(date,food) plt.legend() plt.show() sump_all = getAll(sump) fruit_all =