小说里的章节用 数字、 来划分,
如何用sublime text将这些 数字、 替换成 第 数字 章
远程看看吧
import re
strs=""
with open("2.txt","r",encoding="utf-8") as fp:
txt=fp.readline()
while txt:
tlist=re.findall("\d+、",txt)
if tlist:
temp=tlist[0].replace("、","")
# print(temp)
txt=txt.replace(temp+"、","第"+temp+"章 ")
print(txt)
strs=strs+txt
txt = fp.readline()
with open("1.txt","a",encoding="utf-8") as f:
f.write(strs)