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
# -*- 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.
先看一个很简单的例子 #coding:utf8 import Queue #queue是队列的意思 q=Queue.Queue(maxsize=10) #创建一个queue对象 for i in range(9): q.put(i) #放入元素 while not q.empty():#检测元素是否为空 print q.get(),#读取元素 #默认为先进先出 如果需要一个无限长或者先进后出的队列 #创建一个无限长的队列,如果maxsize小于1就表示队列长度无限. q1=Queue.Queue