AC代码展示
fi = open("论语-网络版.txt","r",encoding="utf-8")
fo = open("论语-提取版.txt","w",encoding="utf-8")
wflag =False
newline = []
for line in fi :
if "【" in line:
wflag =False
if "【原文】" in line:
wflag = True
continue
if wflag == True:
newline = []
K = list(line)
if len(K)>1:
for i in K :
if i!=" ":
newline.append(i)
strlist = "".join(newline)
newlines = str(strlist)
for D in range(1,23):
newlines = newlines.replace("({})".format(D),"")
for P in range(0,25):
for A in range(0,25):
newlines = newlines.replace("{}·{}".format(P,A), "")
for A in range(0,25):
newlines = newlines.replace("{}".format(A), "")
fo.write(newlines)
fo.close()
fi.close()