首页 > 技术文章 > textwrap模块

wc89 2020-04-09 12:19 原文

fill  将多行文本按照指定的宽度和格式输出

s = "Look into my eyes, look into my eyes, the eyes, the eyes, \
the eyes, not around the eyes, don't look around the eyes, \
look into my eyes, you're under."

import textwrap
print(textwrap.fill(s, 70))
print(textwrap.fill(s, 40, initial_indent='    ', subsequent_indent='    '))

 

推荐阅读