temp = '' with open("strings.txt", "r", encoding='UTF-8') as f: list = f.readlines() s = ''.join(list).replace('\n', '').replace('\r', '') # s = s.replace(' ', '')
#选择是否把空格替换掉
print(s) temp = ''.join(s) with open("strings.txt", "w", encoding='UTF-8') as f: f.write(temp)
...删除论文中的换行符
同目录下创建strings.txt即可用