博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
textwrap 模块
阅读量:4582 次
发布时间:2019-06-09

本文共 723 字,大约阅读时间需要 2 分钟。

# -*- coding: utf-8 -*-#python 27#xiaodeng#textwrap 模块#http://www.cnblogs.com/hongten/p/python_textwrap.htmlimport textwrapsample_text = '''   The textwrap module can beused to format text for output in   situations wherepretty-printing is desired.  It offers   programmatic functionalitysimilar to the paragraph wrapping   or filling features found inmany text editors.'''#fill(text, width=70, **kwargs):#该方法可以根据指定的长度,进行拆分字符串,然后逐行显示print textwrap.fill(sample_text,width=20)#wrap(text, width = 70, **kwargs):这个函数可以把一个字符串拆分成一个序列#width,按照特定宽度拆分字符串。print textwrap.wrap(sample_text,width=50)#dedent()方法->文本进行不缩进显示,相应的indent()方法 -> 进行缩进显示print textwrap.dedent(sample_text)

 

转载于:https://www.cnblogs.com/dengyg200891/p/4943777.html

你可能感兴趣的文章
python面试
查看>>
用Docker构建Nginx镜像
查看>>
spring注解-“@Scope”
查看>>
apache错误日志(error_log)记录等级
查看>>
通用的前端注册验证
查看>>
WPF 窗体中的 Canvas 限定范围拖动 鼠标滚轴改变大小
查看>>
django下的 restful规范 Drf框架 psotman的安装使用 及一些容易遗忘的小点
查看>>
Atitit.输入法配置说明v1 q229
查看>>
Atitit main函数的ast分析 数组参数调用的ast astview解析
查看>>
[转载]漫话:如何给女朋友介绍什么是死锁
查看>>
读书笔记——持有对象
查看>>
php header函数导出excel表格
查看>>
Jzoj1277最高的奶牛
查看>>
plsql中文乱码问题(显示问号)
查看>>
C# DataTbale详细操作
查看>>
用opencv检测人眼并定位瞳孔位置
查看>>
实现多项式的JAVA类
查看>>
Getting Started with the G1 Garbage Collector 转发
查看>>
HDU5036 Explosion(期望 bitset)
查看>>
有限自动机的构造和识别
查看>>