-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse.py
37 lines (31 loc) · 954 Bytes
/
analyse.py
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
def analyse():
f=open('templates/hanhan.txt','r')
namelist={}
hanhantalk=""
for s in f:
if ': ' in s:
timestamp=s[:20]
line=s[20:]
a=line.find('] ')
b=line.find(': ')
if(a>0):
tt=a+2
else:
tt=0
bid=line[tt:b]
talk=line[b+1:]
if bid not in namelist:
namelist[bid]=1
else:
namelist[bid]=namelist[bid]+1
if '涵涵_Live2Dモデリング' in bid:
hanhantalk=s+'<br>\n'+hanhantalk
f.close()
# for n in namelist:
# print(n,namelist[n])
ap = sorted(namelist.items(), key=lambda d:d[1], reverse = True)
res="DD发言排行<br>\n"
for i,r in enumerate( ap[0:10]):
res=res+" "+str(i+1)+" "+r[0]+" "+str(r[1])+"<br>"+"\n"
return res,hanhantalk
# print(analyse())