指定段落宽度

import textwrap
doc = """The wrap() method is just like fill() except that it returns
a list of strings instead of one big string with newlines to separate
 the wrapped lines."""
print(textwrap.fill(doc, width=40))

输出

The wrap() method is just like fill()
except that it returns a list of strings
instead of one big string with newlines
to separate  the wrapped lines.

原文地址:https://www.cnblogs.com/sea-stream/p/10002427.html