with open("all.txt", 'r', encoding='utf-8') as f:
file=""
for number, line in enumerate(f, start=1):
if line != "\n":
if len(line) >4 and len(line)<=7 and line[3] != "-" :
line = line[0:3]+"\n"+"\n"+line[3:]
file += line
with open("all2.txt",'w',encoding='utf-8') as f:
f.write(file)
f.close()
文本中实现每行指定位置插入字符串
最新推荐文章于 2023-01-04 14:19:00 发布