Я хочу создать файл text_out.txt путем обращения слов в text_in.txt в файл, подобный этому:
text_in.txt имеет два абзаца , как показано ниже:
Hello world, I am Here.
I am eighteen years old.
text_out.txt должен быть таким:
Here. am I world, Hello
old. years eighteen am I
Мой код:
filein = open ('text_in.txt', 'r+')
fileout = open ('text_out.txt', 'w')
data = filein.read()
array1 = data.split(' ')
array1.reverse()
out1 = " " .join(array1)
fileout.write(out1)
Мои результаты old. years eighteen am I \nHere. am I world, Hello
Может ли кто-нибудь помочь мне решить эту проблему? Большое спасибо!