# -*- coding: utf-8 -*- #python 27 #xiaodeng #textwrap 模块 #http://www.cnblogs.com/hongten/p/python_textwrap.html import textwrap sample_text = ''' The textwrap module can beused to format text for output in situations wherepretty-printing is desired.…
textwrap模块提供了两个函数wrap()和fill(),以及TextWrapper类,以及另外一个工具函数dedent(). wrap()以及fill()都可以用来格式化一大段文本,将指定文本限制在一定的屏幕宽度.例如 >>> import textwrap >>> doc = """The wrap() method is just like fill() except that it returns ... a l…
介绍:需要美观打印时,可以使用textwrap模块来格式化要输出的文本,这个模块允许通过编程提高类似段落自动换行或填充特性等功能. 1 创建实例数据 sample_text = ''' I’m very happy and I like to make friends with others. I also like singing but traveling is my favorite, I have been to many interesting places in China but…
textwrap textwrap模块可以用来格式化文本, 使其在某些场合输出更美观. 他提供了一些类似于在很多文本编辑器中都有的段落包装或填充特性的程序功能. Example Data 本节中的示例使用模块textwrap_example.py,它包含一个字符串sample_text. sample_text = ''' The textwrap module can be used to format text for output in situations where pretty-pr…
介绍 需要美观打印(pretty-printing)的情况下,可以使用textwrap模块格式化要输出的文本. 它提供了很多文本编辑器和字符处理器中都有的段落自动换行或填充特性 填充段落 import textwrap text = ''' There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! D…