打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

RIA Wiki 已更新到 1.41!部分 CSS 在新版本下可能有不同的表现,请编辑者注意检查和修改。 目前wiki关闭了自行注册账号的功能,如需注册账号,请查阅Help:注册账号

Coi统计数据程序:修订间差异

来自RIA | Wiki
Arthals留言 | 贡献
无编辑摘要
Aunst留言 | 贡献
分类...
 
(未显示2个用户的5个中间版本)
第1行: 第1行:
<code>import os</code>
== 主程序·RIA_COI_MAIN ==
<pre>
import tkinter as tk


<code>import os.path</code>
import tkinter.messagebox


<code>def is_number(s):</code>
import os


<code>try:</code>
import os.path


<code>float(s)</code>
import tkinter.messagebox


<code>return True</code>
from PIL import ImageTk, Image


<code>except ValueError:</code>
from tkinter import filedialog


<code>return False</code>
import base64


<code>def replaceList(list1, num, replace):</code>
logID=""


<code>list2 =[]</code>
root=""


<code>for i in range(len(list1)):</code>
TimeLog1=0


<code>if i == num:</code>
TimeLog2=0


<code>list2.append(replace)</code>
config=""


<code>else:</code>
def is_number(s):


<code>list2.append(list1[i])</code>
try:


<code>return list2</code>
float(s)


<code>def part(num,list1):</code>
return True


<code>for i in range(len(list1)):</code>
except ValueError:


<code>if num<=list1[i]:</code>
return False


<code>return i</code>
def replaceList(list1, num, replace):


<code>break</code>
list2 =[]


<code>root=str(input("请输入文件目录路径(不含有/coi.txt):"))</code>
for i in range(len(list1)):


<code>print("——Welcome!欢迎来到RCB援建数据统计系统,by Arthals——")</code>
if i == num:


<code>logID=str(input("请输入统计人ID:"))</code>
list2.append(replace)


<code>TimeLog1=float(input("请输入较小的时间刻度(正整数):"))</code>
else:


<code>TimeLog2=float(input("请输入较大的时间刻度(正整数):"))</code>
list2.append(list1[i])


<code>config=str(input("是否删除数量为54的数据,如果是,请输入yes;如果不是,请输入no:"))</code>
return list2


<code>data=open(str(root+"/coi.txt"),"r")</code>
def part(num,list1):


<code>len_logID=len(logID)</code>
for i in range(len(list1)):


<code>coi=[]</code>
if num<=list1[i]:


<code>all_coi_name=[]</code>
return i


<code>all_coi_value=[]</code>
break


<code>count=[]</code>
def go():


<code>all_coi={}</code>
logID=str(entry.get())


<code>tag=[]</code>
root=filedialog.askopenfilename()


<code>for line in data:</code>
TimeLog1=float(entry_TimeLog1.get())


<code>coi.append(str(line))</code>
TimeLog2=float(entry_TimeLog2.get())


<code>for i in range(len(coi)):</code>
config=tkinter.messagebox.askquestion("选择","是否删除x54的数据")


<code>line=coi[i]</code>
data=open(str(root),"r",encoding="UTF-8")


<code>if line[40:47+len_logID]==str("* "+logID+" 统计结束"):</code>
len_logID=len(logID)


<code>break</code>
coi=[]


<code>if line[40:46+len_logID]==str("* "+logID+" 统计:"):</code>
all_coi_name=[]


<code>tag.append(line[46+len_logID:].rstrip("\n"))</code>
all_coi_value=[]


<code>print("Now:",line[43+len_logID:].rstrip(""))</code>
count=[]


<code>coi2=[]</code>
all_coi={}


<code>how={}</code>
tag=[]


<code>for l in range(i+1,len(coi)):</code>
for mine in data:


<code>if coi[l][40:45+len_logID]=="* "+logID+" 统计":</code>
coi.append(str(mine))


<code>break</code>
for i in range(len(coi)):


<code>else:</code>
if len(coi[i])<=39:


<code>t_f = is_number(coi[l][41])</code>
continue


<code>if t_f == True:</code>
linex=coi[i].split(" ")


<code>linex=coi[l][40:]</code>
if len(linex)<7:


<code>linex_list=linex.split(" ")</code>
continue


<code>time=float(linex_list[0].rstrip("/h"))</code>
linex=linex[4:]


<code>if TimeLog1<=time<=TimeLog2:</code>
if linex[0]=="*" and linex[1]==logID and linex[2]=="统计结束\n":


<code>linex_list.remove("ago")</code>
break


<code>linex_list.remove("-")</code>
elif linex[0]=="*" and linex[1]==logID and linex[2][:3]=="统计:":


<code>linex_list.pop()</code>
tag.append(linex[2][3:].rstrip("\n"))


<code>if config=="yes" and linex_list[3]=="x54":</code>
coi2=[]


<code>continue</code>
how={}


<code>if linex_list[2]=="removed":</code>
for l in range(i+1,len(coi)):


<code>if linex_list[1] in how:</code>
if coi[l][40:45+len(logID)]=="* "+logID+" 统计":


<code>how[linex_list[1]]=how[linex_list[1]]-int(linex_list[3].lstrip("x"))</code>
break


<code>elif linex_list[1] not in how:</code>
else:


<code>how[linex_list[1]]=-int(linex_list[3].lstrip("x"))</code>
t_f = is_number(coi[l][40])


<code>else:</code>
if t_f == True:


<code>print("Error")</code>
liney=coi[l][40:]


<code>break</code>
linex_list=liney.split(" ")


<code>if linex_list[2]=="added":</code>
time=float(linex_list[0].rstrip("/h"))


<code>if linex_list[1] in how:</code>
if TimeLog1<=time<=TimeLog2:


<code>how[linex_list[1]]=how[linex_list[1]]+int(linex_list[3].lstrip("x"))</code>
linex_list.remove("ago")


<code>elif linex_list[1] not in how:</code>
linex_list.remove("-")


<code>how[linex_list[1]]=int(linex_list[3].lstrip("x"))</code>
linex_list.pop()


<code>else:</code>
if config=="yes" and linex_list[3]=="x54":


<code>print("Error")</code>
continue


<code>break</code>
if linex_list[2]=="removed":


<code>name=list(how.keys())</code>
if linex_list[1] in how:


<code>count.append(len(name))</code>
how[linex_list[1]]=how[linex_list[1]]-int(linex_list[3].lstrip("x"))


<code>for y in range(len(name)):</code>
elif linex_list[1] not in how:


<code>all_coi_name.append(name[y])</code>
how[linex_list[1]]=-int(linex_list[3].lstrip("x"))


<code>value=list(how.values())</code>
else:


<code>for y in range(len(value)):</code>
print("Error")


<code>all_coi_value.append(value[y])</code>
break


<code>sort=[]</code>
if linex_list[2]=="added":


<code>for i in range(len(all_coi_name)):</code>
if linex_list[1] in how:


<code>if all_coi_name[i] in sort:</code>
how[linex_list[1]]=how[linex_list[1]]+int(linex_list[3].lstrip("x"))


<code>continue</code>
elif linex_list[1] not in how:


<code>else:</code>
how[linex_list[1]]=int(linex_list[3].lstrip("x"))


<code>sort.append(all_coi_name[i])</code>
else:


<code>sort.sort()</code>
print("Error")


<code>all_count=[]</code>
break


<code>for i in range(len(count)):</code>
name=list(how.keys())


<code>if i==0:</code>
count.append(len(name))


<code>all_count.append(count[i])</code>
for y in range(len(name)):


<code>else:</code>
all_coi_name.append(name[y])


<code>all_count.append("0")</code>
value=list(how.values())


<code>all_count=replaceList(all_count,i,int(count[i]+all_count[i-1]))</code>
for y in range(len(value)):


<code>all_count_change=[]</code>
all_coi_value.append(value[y])


<code>for i in range(len(all_count)):</code>
sort=[]


<code>all_count_change.append(int(all_count[i]-1))</code>
for i in range(len(all_coi_name)):


<code>all_count=all_count_change</code>
if all_coi_name[i] in sort:


<code>bt=[]</code>
continue


<code>for i in range(len(tag)+2):</code>
else:


<code>if i==0:</code>
sort.append(all_coi_name[i])


<code>bt.append("ID\t")</code>
sort.sort()


<code>elif i != len(tag)+1:</code>
all_count=[]


<code>bt.append(str(tag[i-1])+"\t")</code>
for i in range(len(count)):


<code>else:</code>
if i==0:


<code>bt.append(str("\n"))</code>
all_count.append(count[i])


<code>change=[]</code>
else:


<code>for i in range(len(all_coi_value)):</code>
all_count.append("0")


<code>change.append(abs(all_coi_value[i]))</code>
all_count=replaceList(all_count,i,int(count[i]+all_count[i-1]))


<code>all_coi_value=change</code>
all_count_change=[]


<code>log=open(str(root+"/result.txt"),"a+")</code>
for i in range(len(all_count)):


<code>btpr=""</code>
all_count_change.append(int(all_count[i]-1))


<code>for i in range(len(bt)):</code>
all_count=all_count_change


<code>btpr=btpr+str(bt[i])</code>
bt=[]


<code>log.write(btpr)</code>
for i in range(len(tag)+2):


<code>print(btpr)</code>
if i==0:


<code>change1=[]</code>
bt.append("ID\t")


<code>for i in range(len(all_coi_value)):</code>
elif i != len(tag)+1:


<code>if all_coi_value[i]!=0:</code>
bt.append(str(tag[i-1])+"\t")


<code>change1.append(all_coi_value[i])</code>
else:


<code>else:</code>
bt.append(str("\n"))


<code>change1.append("")</code>
change=[]


<code>all_coi_value=change1</code>
for i in range(len(all_coi_value)):


<code>for i in range(len(sort)):</code>
change.append(-(all_coi_value[i]))


<code>pr=str(sort[i]+"\t")</code>
all_coi_value=change


<code>dic={}</code>
log=open(str(root.rstrip("coi.txt")+"result.txt"),"w+",encoding="UTF-8")


<code>for x in range(len(tag)):</code>
btpr=""


<code>dic[x]="\t"</code>
for i in range(len(bt)):


<code>for l in range(len(all_coi_name)):</code>
btpr=btpr+str(bt[i])


<code>if all_coi_name[l]==sort[i]:</code>
log.write(btpr)


<code>n=part(l,all_count)</code>
change1=[]


<code>dic[n]=all_coi_value[l]</code>
for i in range(len(all_coi_value)):


<code>print(sort[i],"\n",dic,"\n————————————————————")</code>
if all_coi_value[i]!=0:


<code>for m in range(len(dic)):</code>
change1.append(all_coi_value[i])


<code>if m !=len(dic)-1:</code>
else:


<code>if str(list(dic.values())[m])=="\t":</code>
change1.append("")


<code>pr=pr+str(list(dic.values())[m])</code>
all_coi_value=change1


<code>else:</code>
for i in range(len(sort)):


<code>pr=pr+str(list(dic.values())[m])+"\t"</code>
pr=str(sort[i]+"\t")


<code>else:</code>
dic={}


<code>if str(list(dic.values())[m])=="\t":</code>
for x in range(len(tag)):


<code>pr=pr+"\n"</code>
dic[x]="\t"


<code>else:</code>
for l in range(len(all_coi_name)):


<code>pr=pr+str(list(dic.values())[m])+"\n"</code>
if all_coi_name[l]==sort[i]:


<code>log.write(pr)</code>
n=part(l,all_count)


<code>log.close()</code>
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:程序源代码]]

2021年3月27日 (六) 22:25的最新版本

主程序·RIA_COI_MAIN

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()

图片转换程序

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")