每天CookBook之Python-036

  • 按照固定宽度格式化文本段落
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."

print(s)

import textwrap

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

import os

print(os.get_terminal_size().columns)
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.
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.
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.
          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.
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 unde
posted @ 2016-07-15 22:35  4Thing  阅读(85)  评论(0编辑  收藏  举报