-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.py
More file actions
34 lines (27 loc) · 665 Bytes
/
help.py
File metadata and controls
34 lines (27 loc) · 665 Bytes
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
import os
dirnum = 0
filenum = 0
path = './notes'
for lists in os.listdir(path):
sub_path = os.path.join(path, lists)
print(sub_path)
if os.path.isfile(sub_path):
filenum = filenum+1
elif os.path.isdir(sub_path):
dirnum = dirnum+1
print('dirnum: ',dirnum)
print('filenum: ',filenum)
with open('README.md') as f:
lines = f.readlines()
for i, line in enumerate(lines):
if line.startswith("- There are"):
idx = i
break
if idx:
lines[idx] = '- There are totally <big>**{}**</big> solutions in this repo.\n'.format(dirnum)
f = open('README.md','w')
res = ""
for line in lines:
res += line
f.write(res)
f.close()