打开/关闭搜索
搜索
打开/关闭菜单
1706
4999
924
6.3万
RIA | Wiki
导航
首页
最近更改
随机页面
MediaWiki帮助
上传文件
RIA社群
RIA官网&红报社
RIA论坛
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
登录
目前wiki关闭了自行注册账号的功能,如需注册账号,请查阅
Help:注册账号
。
查看“︁Coi统计数据程序”︁的源代码
来自RIA | Wiki
分享此页面
查看
阅读
查看源代码
查看历史
associated-pages
页面
讨论
更多操作
←
Coi统计数据程序
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于这些用户组的用户执行:
用户
、已验证用户
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
== 主程序·RIA_COI_MAIN == <pre> import tkinter as tk import tkinter.messagebox import os import os.path import tkinter.messagebox from PIL import ImageTk, Image from tkinter import filedialog import base64 logID="" root="" TimeLog1=0 TimeLog2=0 config="" def is_number(s): try: float(s) return True except ValueError: return False def replaceList(list1, num, replace): list2 =[] for i in range(len(list1)): if i == num: list2.append(replace) else: list2.append(list1[i]) return list2 def part(num,list1): for i in range(len(list1)): if num<=list1[i]: return i break def go(): logID=str(entry.get()) root=filedialog.askopenfilename() TimeLog1=float(entry_TimeLog1.get()) TimeLog2=float(entry_TimeLog2.get()) config=tkinter.messagebox.askquestion("选择","是否删除x54的数据") data=open(str(root),"r",encoding="UTF-8") len_logID=len(logID) coi=[] all_coi_name=[] all_coi_value=[] count=[] all_coi={} tag=[] for mine in data: coi.append(str(mine)) for i in range(len(coi)): if len(coi[i])<=39: continue linex=coi[i].split(" ") if len(linex)<7: continue linex=linex[4:] if linex[0]=="*" and linex[1]==logID and linex[2]=="统计结束\n": break elif linex[0]=="*" and linex[1]==logID and linex[2][:3]=="统计:": tag.append(linex[2][3:].rstrip("\n")) coi2=[] how={} for l in range(i+1,len(coi)): if coi[l][40:45+len(logID)]=="* "+logID+" 统计": break else: t_f = is_number(coi[l][40]) if t_f == True: liney=coi[l][40:] linex_list=liney.split(" ") time=float(linex_list[0].rstrip("/h")) if TimeLog1<=time<=TimeLog2: linex_list.remove("ago") linex_list.remove("-") linex_list.pop() if config=="yes" and linex_list[3]=="x54": continue if linex_list[2]=="removed": if linex_list[1] in how: how[linex_list[1]]=how[linex_list[1]]-int(linex_list[3].lstrip("x")) elif linex_list[1] not in how: how[linex_list[1]]=-int(linex_list[3].lstrip("x")) else: print("Error") break if linex_list[2]=="added": if linex_list[1] in how: how[linex_list[1]]=how[linex_list[1]]+int(linex_list[3].lstrip("x")) elif linex_list[1] not in how: how[linex_list[1]]=int(linex_list[3].lstrip("x")) else: print("Error") break name=list(how.keys()) count.append(len(name)) for y in range(len(name)): all_coi_name.append(name[y]) value=list(how.values()) for y in range(len(value)): all_coi_value.append(value[y]) sort=[] for i in range(len(all_coi_name)): if all_coi_name[i] in sort: continue else: sort.append(all_coi_name[i]) sort.sort() all_count=[] for i in range(len(count)): if i==0: all_count.append(count[i]) else: all_count.append("0") all_count=replaceList(all_count,i,int(count[i]+all_count[i-1])) all_count_change=[] for i in range(len(all_count)): all_count_change.append(int(all_count[i]-1)) all_count=all_count_change bt=[] for i in range(len(tag)+2): if i==0: bt.append("ID\t") elif i != len(tag)+1: bt.append(str(tag[i-1])+"\t") else: bt.append(str("\n")) change=[] for i in range(len(all_coi_value)): change.append(-(all_coi_value[i])) all_coi_value=change log=open(str(root.rstrip("coi.txt")+"result.txt"),"w+",encoding="UTF-8") btpr="" for i in range(len(bt)): btpr=btpr+str(bt[i]) log.write(btpr) change1=[] for i in range(len(all_coi_value)): if all_coi_value[i]!=0: change1.append(all_coi_value[i]) else: change1.append("") all_coi_value=change1 for i in range(len(sort)): pr=str(sort[i]+"\t") dic={} for x in range(len(tag)): dic[x]="\t" for l in range(len(all_coi_name)): if all_coi_name[l]==sort[i]: n=part(l,all_count) dic[n]=all_coi_value[l] for m in range(len(dic)): if m !=len(dic)-1: if str(list(dic.values())[m])=="\t": pr=pr+str(list(dic.values())[m]) else: pr=pr+str(list(dic.values())[m])+"\t" else: if str(list(dic.values())[m])=="\t": pr=pr+"\n" else: pr=pr+str(list(dic.values())[m])+"\n" log.write(pr) log.close() tkinter.messagebox.showinfo("Congratulations!","数据处理完毕。") roo = tk.Tk() roo.title('RIA 援建数据处理系统GUI by Arthals') canvas = tk.Canvas(roo, width=769,height=432,bd=0, highlightthickness=0) from RIABG_png import img as socket imp = open('RIABG.png', 'wb') imp.write(base64.b64decode(socket)) imp.close() imgpath = 'RIABG.png' img = Image.open(imgpath) photo = ImageTk.PhotoImage(img) canvas.create_image(0, 0, anchor="nw", image=photo) canvas.pack() entry=tk.Entry(roo,insertbackground='blue', highlightthickness =2) ''' entry_root=tk.Entry(roo,insertbackground='blue', highlightthickness =2) ''' entry_TimeLog1=tk.Entry(roo,insertbackground='blue', highlightthickness =2) entry_TimeLog2=tk.Entry(roo,insertbackground='blue', highlightthickness =2) ''' entry_config=tk.Entry(roo,insertbackground='blue', highlightthickness =2) ''' entry.pack() ''' entry_root.pack() ''' entry_TimeLog1.pack() entry_TimeLog2.pack() ''' entry_config.pack() ''' button=tkinter.Button(roo,text="进行统计",font=('黑体', 20),bg="green",command=go) button.pack() canvas.create_window(60, 50, anchor="nw",width=100, height=30,window=entry) ''' canvas.create_window(120, 120, width=100, height=20,window=entry_root) ''' canvas.create_window(60, 130, anchor="nw",width=70, height=25,window=entry_TimeLog1) canvas.create_window(60, 190, anchor="nw",width=70, height=25,window=entry_TimeLog2) ''' canvas.create_window(120, 160, width=100, height=20,window=entry_config) ''' canvas.create_window(720, 350,anchor="ne", width=235, height=60,window=button) roo.mainloop() </pre> == 图片转换程序 == <pre> import base64 def pic2py(picture_name): """ 将图像文件转换为py文件 :param picture_name: :return: """ open_pic = open("%s" % picture_name, 'rb') b64str = base64.b64encode(open_pic.read()) open_pic.close() # 注意这边b64str一定要加上.decode() write_data = 'img = "%s"' % b64str.decode() f = open('%s.py' % picture_name.replace('.', '_'), 'w+') f.write(write_data) f.close() if __name__ == '__main__': pics = ["RIABG.png"] for i in pics: pic2py(i) print("ok") </pre> <!-- 分类 --> [[Category:怪东西]] [[Category:程序源代码]]
返回
Coi统计数据程序
。
查看“︁Coi统计数据程序”︁的源代码
来自RIA | Wiki