我是靠谱客的博主 兴奋啤酒,最近开发中收集的这篇文章主要介绍python中怎么写一个替代txt文本所有回车为空格的程序 ,使文本只有了连续一行 ?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

每次翻译外文文献的时候,把英文复制到谷歌翻译,会出现PDF格式的文本的换行很麻烦,需要手动来删除换行,影响翻译时思考的质量。

于是,我可不可以用python来解决这个问题呢?

with open('etext.txt','r') as fp:
    data = fp.readlines()
data = [line.strip() for line in data]
data = ','.join(data)
data = data.split(',')
data = ' '.join(map(str,data))
with open('welltext.txt','w') as fp:
    fp.write(data)

这样就能将

It is widely recognized that a visual texture, which humans
can easily perceive, is very difficult to define [17]. The difficulty
results mainly from the fact that different people can define textures
in application-dependent ways or with different perceptual
motivations, and there is no generally agreed-upon definition
[44]. It is not our intention to add here a new one: we simply
observe that it should be as general as possible, because a too
strict definition would allow one to confine his/her work to images
that better fit with it, eventually leading to narrow-domain
solutions.

转换成

It is widely recognized that a visual texture  which humans can easily perceive  is very difficult to define [17]. The difficulty results mainly from the fact that different people can define textures in application-dependent ways or with different perceptual motivations  and there is no generally agreed-upon definition [44]. It is not our intention to add here a new one: we simply observe that it should be as general as possible  because a too strict definition would allow one to confine his/her work to images that better fit with it  eventually leading to narrow-domain solutions.

在谷歌翻译里就是从这样


到这样




最后

以上就是兴奋啤酒为你收集整理的python中怎么写一个替代txt文本所有回车为空格的程序 ,使文本只有了连续一行 ?的全部内容,希望文章能够帮你解决python中怎么写一个替代txt文本所有回车为空格的程序 ,使文本只有了连续一行 ?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(44)

评论列表共有 0 条评论

立即
投稿
返回
顶部