python怎么自动换行,python回车怎么表示
例如,文件包含以下字符串:
a.txt
re i9 aiwebohth4zu go3 eimumichiesh 5
ive es H2 jei ziv0BOL U2 efoozfeey5ohr
要转变为以下形势:
b.txt
Rei9aiwe
bohth4Zu
Go3eimum
iChieSh5
iveeSh2J
eiziV0bo
lu2Efooz
feey5Ohr
怎么做?
不问语言。 PHP/Ruby/Python也可以。
既然语言没有限制,就会有别的语言来。 目测不知道是什么语言。 import [ ' a.txt ' ]~string replace~('-'\n ' )//Export['b.txt ',#]
添加ruby版open(b.txt )、(w ) ).puts open (a.txt ).read.gsub )和(\n )
pythonmyfile=open(a.txt ) )。
temp=' '
for line in myfile.readlines () :
for a in line.split () :
temp =a '\n '
myfile.close (
file_object=open('b.txt ',' w ' ) )。
file_object.writelines(temp )
file_object.close(sed's/\s )/\n/g'a.txtb.txt
或tr ' ' '\n' a.txt b.txt
或者,python:python-c'open(b.txt、一分快三大小单双位技巧准确率99/p>
myfile.close (
file_object=open('b.txt ',' w ' ) )。
file_object.writelines(temp )
file_object.close(sed's/\s )/\n/g'a.txtb.txt
或tr ' ' '\n' a.txt b.txt
或者,python:python-c'open(b.txt、' w ' ).write ) open (a.txt ).read ).replace )、'\n ' )
这样的任务,超过一行的代码真的很浪费。
蛇网的文章、转载请注明出处和文章网站。 https://www.iplay py.com/wenda/wd 20182.html
相关文章Recommend