-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplace.py
37 lines (33 loc) · 1.11 KB
/
replace.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
37
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from glob import glob
def zh_ch2en_us(files):
for file in files:
print(file)
f = open(file, 'r+', encoding='utf-8')
all_the_lines = f.readlines()
f.seek(0)
f.truncate()
for line in all_the_lines:
line = line.replace(',', ',')
line = line.replace('。', '.')
line = line.replace('(', '(')
line = line.replace(')', ')')
line = line.replace('“', '\"')
line = line.replace('”', '\"')
line = line.replace(':', ':')
line = line.replace(';', ';')
line = line.replace('?', '?')
line = line.replace('!', '!')
line = line.replace('《', '<')
line = line.replace('》', '>')
line = line.replace('【', '[')
line = line.replace('】', ']')
line = line.replace('、', '\\')
line = line.replace('~', '~')
f.write(line)
f.close()
if __name__ == '__main__':
path = glob('*.md')
print(path)
zh_ch2en_us(path)