Python:Writelines-从头到尾

我正在提取一个在线文本文档,然后将其重新打印到文本文件。问题是,一行中仅打印约70个字符,这与文档在线显示的方式一致。我想更改它,以便所有行都环绕,然后一直到文本文档的边缘,然后再返回。或者,我希望能够重置打印到一行的字符数,例如100或120。而不是70。但是,我无法执行此操作。

Please see the following photo: Paragraph 1 is how I'd like it to come out, paragraph 2 is how they actually come out.

下面是我的代码:

import requests
from bs4 import BeautifulSoup

page = requests.get("http://classics.mit.edu/Aristotle/rhetoric.mb.txt")

soup = BeautifulSoup(page.text,"html.parser")

with open("Art_of_Rhetoric.txt", "w") as file_object:
    #soup.text.replace("\r\n","")
    file_object.write(soup.text)

我尝试了很多事情。包含:

  • Putting the text into a list, line by line, and then trying to print out the lines. I only just duplicated the lines I printed.
  • As you can see, I tried to search for any line breaks that were within the next and remove them. That also didn't work.
  • I even found This in some python documentation, but it only seems to allow you to print out up to 70 characters a line anyway.

我很确定有一个简单的解决方案,我只是不知道它是什么。

我希望文本文档的输出类似于上面“第1款”中的输出。当前,输出的输出方式类似于标记为“第2段”的段落。