1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
| def Visual(ms): all=ms.Look("select * from infor") start = "+------选择功能-------+\n" start += "| 1.按年显示 |\n" start += "| 2.按月显示 |\n" start += "| 3.按日显示 |\n" start += "| 4.退出程序 |\n" start += "+---------end---------+\n" print(start) judge = int(input("请输入执行功能:")) while (judge !=4): if (judge==1): strbeginyear=str(all[0][4])[0:4] strendyear=str(all[-1][4])[0:4] oneyear=int(strbeginyear) everymoneys=[] summoneys=[] thislist = [] while oneyear <=int(strendyear): onest=ms.Look("select * from infor where datetime regexp '"+str(oneyear)+"'") if(onest !=()): onemoney = onest[-1][3] - onest[0][3] + onest[0][2] onesum = onest[-1][3] everymoneys.append(onemoney) summoneys.append(onesum) thislist.append(oneyear) oneyear += 1 else: oneyear+=1 xtick = (np.arange(len(thislist))) plt.subplot() matplotlib.rcParams["font.family"] = "KaiTi" plt.bar(xtick,everymoneys,0.3,label="各年收支") plt.plot(xtick, summoneys, "--r",label="累计收支") plt.xlabel("年份",fontproperties="KaiTi",size=14) plt.ylabel("金额(¥)",fontproperties="KaiTi",size=14) plt.title("各年份收支信息",fontproperties="KaiTi",size=22) plt.legend() plt.xticks(xtick) plt.show() elif(judge==2): year=input("请输入年份:") partyear=ms.Look("select * from infor where datetime regexp '" + year + "'") strbeginmonth = str(partyear[0][4])[5:7] strendmonth=str(partyear[-1][4])[5:7] onemonth = int(strbeginmonth) everymoneys = [] summoneys = [] monthlist=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"] thislist=[] monthcount=int(strbeginmonth) while onemonth <= int(strendmonth): onest = ms.Look("select * from infor where datetime regexp '" +year+"-"+ "0*"+str(onemonth) + "'") if(onest !=()): onemoney = onest[-1][3] - onest[0][3] + onest[0][2] onesum = onest[-1][3] everymoneys.append(onemoney) summoneys.append(onesum) thislist.append(monthlist[onemonth-1]) onemonth += 1 else: onemonth += 1 xtick = (np.arange(len(thislist))) plt.subplot() matplotlib.rcParams["font.family"] = "KaiTi" plt.bar(xtick, everymoneys, 0.3,label="各月收支") plt.plot(xtick, summoneys, "--r",label="累计收支") plt.xlabel("月份", fontproperties="KaiTi", size=14) plt.ylabel("金额(¥)",fontproperties="KaiTi", size=14) plt.title(year+"年各月份收支信息", fontproperties="KaiTi", size=22) plt.xticks(xtick,thislist,fontproperties="KaiTi",size=14) plt.legend() plt.show() elif (judge==3): year = input("请输入年份:") month = input("请输入月份:") partmonth = ms.Look("select * from infor where datetime regexp '" + year +"-"+"0*"+month+ "'") strbeginday = str(partmonth[0][4])[8:10] strendday = str(partmonth[-1][4])[8:10] oneday = int(strbeginday) everymoneys = [] summoneys = [] thislist = [] daycount = int(strbeginday) while oneday <= int(strendday): onest = ms.Look("select * from infor where datetime regexp '" + year + "-" + "0*" + month +"-0*"+str(oneday)+ "'") if (onest != ()): onemoney = onest[-1][3] - onest[0][3] + onest[0][2] onesum = onest[-1][3] everymoneys.append(onemoney) summoneys.append(onesum) thislist.append(oneday) oneday += 1 else: oneday += 1 xtick = (np.arange(len(thislist))) plt.subplot() matplotlib.rcParams["font.family"] = "KaiTi" plt.bar(xtick, everymoneys, 0.3,label="各天收支") plt.plot(xtick, summoneys, "--r",label="累计收支") plt.xlabel("天", fontproperties="KaiTi", size=14) plt.ylabel("金额(¥)", fontproperties="KaiTi", size=14) plt.title(year+"年"+month+"月每日收支信息", fontproperties="KaiTi", size=22) plt.xticks(xtick, thislist, fontproperties="KaiTi", size=14) plt.legend() plt.show() print(start) judge = int(input("请输入执行功能:"))
|