textwrap模块1-fill()
来源:互联网 发布:柯桥司法拍卖淘宝网 编辑:程序博客网 时间:2024/05/14 15:42
fill()函数取文本作为输入,生成格式化的文本作为输出。
一、生成一个示例数据模块(textwrap_example.py)
sample_text = '''
The textwrap module can be used to format text for output in
situations where pretty-printing is desired. It offers
programmatic functionality similar to the paragraph wrapping
or filling features found in many text editors.
'''
二、利用fill函数进行格式化输出
import textwrap
from textwrap_example import sample_text
print 'No dedent:\n'
print textwrap.fill(sample_text,width=50)
结果:
No dedent:
The textwrap module can be used to format
text for output in situations where pretty-
printing is desired. It offers programmatic
functionality similar to the paragraph wrapping
or filling features found in many text editors.
如果width的值为60,
结果:
No dedent:
The textwrap module can be used to format text for
output in situations where pretty-printing is desired.
It offers programmatic functionality similar to the
paragraph wrapping or filling features found in many
text editors.
- textwrap模块1-fill()
- python textwrap模块
- python模块学习- textwrap 文本包装和填充
- python2.7中模块学习- textwrap 文本包装和填充
- fill ()
- fill
- Fill
- fill
- 3.4 textwrap--格式化文本库
- textwrap提供了一些方法
- 3.4 textwrap--格式化文本库(2)
- SqlDataAdapter.Fill
- fill用法
- Fill填充
- fill详解
- 10603 - Fill
- uva10603 - Fill
- UVaOJ10603 - Fill
- JavaScript学习笔记(二十七) 常量
- hdu1222-Wolf and Rabbit
- 使用commons-fileupload组件实现文件上传
- linux驱动学习--第二天:设备驱动概述(二)之安装虚拟环境用VmWare 搭建两台虚拟机
- 进程集合的简易实现
- textwrap模块1-fill()
- Fixjs——显示容器基类DisplayObjectContainer
- HDU 2473 Junk-Mail Filter
- cocos2d-x colorlayer颜色布景层
- scrollLeft,scrollTop,滚动代码的总结
- “Ping”的幕后过程
- Dom用法速查大全
- ios UIVIEW window 的组织结构
- 安卓使用http下载文件