forked from cdhe/JavaSecInterview
-
Notifications
You must be signed in to change notification settings - Fork 5
/
auto.py
30 lines (28 loc) · 922 Bytes
/
auto.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
# 自动更新数量统计
index = open("README.md", "r+", encoding="utf-8");
lines = index.readlines()
all = 0
all_index = 0
for i in range (0,len(lines)):
if lines[i].startswith("["):
line = lines[i]
suffix = line.split("tree/master/")[1]
suffix = suffix.split(")")[0]
temp = open(suffix + "/" + "README.md", "r", encoding="utf-8")
temp_lines = temp.readlines()
total = 0
for q in temp_lines:
if q.startswith("###"):
total = total + 1
p = line.split("-")[0]
s = line.split("个]")[1]
all += total
lines[i] = p + "- " + str(total) + "个]" + s
print(suffix + ":" + str(total))
if lines[i].startswith("当前问题总数"):
all_index = i
print("total:" + str(all))
lines[all_index] = "当前问题总数:"+ str(all) + "\n"
index.seek(0)
index.truncate()
index.writelines(lines)