-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpretext.py
More file actions
35 lines (31 loc) · 814 Bytes
/
pretext.py
File metadata and controls
35 lines (31 loc) · 814 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
34
import shutil
import re
import time
readPath='content_page_list.txt'
writePath='content_page_list_tichong.txt'
lines_seen=set()
outfiile=open(writePath,'a+',encoding='utf-8')
f=open(readPath,'r',encoding='utf-8')
for line in f:
if line not in lines_seen:
outfiile.write(line)
lines_seen.add(line)
lineList=[]
matchPattern1 = re.compile(r'index')
matchPattern2 = re.compile(r'sitemap')
file=open('content_page_list_tichong.txt','r',encoding='UTF-8')
while 1:
line=file.readline()
if not line:
print("读取文件出错!")
break
elif matchPattern1.search(line):
pass
else:
lineList.append(line)
file.close()
file=open(r'content_page_list_tichong_tichu.txt','w',encoding='UTF-8')
for i in lineList:
file.write(i)
print(i)
file.close()