with open('t.txt', 'r', encoding='utf-8') as f: lines = f.readlines()

result = [] for i in range(len(lines)): line = lines[i].strip() if i < len(lines) - 1: next_line = lines[i+1].strip() else: next_line = '' if line[-1] != '。' and next_line and next_line[0] != '。': line += next_line if 'because' in line and line.index('because') != 0: line = line.replace('because', '\nbecause') result.append(line)

with open('output.txt', 'w', encoding='utf-8') as f: f.write('\n'.join(result))

写出脚本 apy1 ttxt 文件中非句号结尾的句子和下一行拼接2 如果 because不在句子开头就在because前断开换行

原文地址: http://www.cveoy.top/t/topic/GJV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录