指定段落宽度

 

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.

 

posted @ 2018-11-22 17:27  anobscureretreat  阅读(199)  评论(0)    收藏  举报