易截截图软件、单文件、免安装、纯绿色、仅160KB

[Python module] queue

8.8. queue — A synchronized queue class¶
queue -- 一个同步队列类
The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implements all the required locking semantics. It depends on the availability of thread support in Python; see the threading module.
queue模块处理多生产者和多消费者的队列。在多线程间信息的安全交换非常有用。这个module的Queue类处理所需的locking语义,它依赖于threading模块。
Implements three types of queue whose only difference is the order that the entries are retrieved. In a FIFO queue, the first tasks added are the first retrieved. In a LIFO queue, the most recently added entry is the first retrieved (operating like a stack). With a priority queue, the entries are kept sorted (using the heapq module) and the lowest valued entry is retrieved first.
三种类型的队列,FIFO,LIFO,以及优先队列(使用heapq模块,先取得低优先级)。
The queue module defines the following classes and exceptions:
class queue.Queue(maxsize)¶Constructor for a FIFO queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.
创建FIFP队列。maxsiaze <= 0, 无限制
class queue.LifoQueue(maxsize)¶Constructor for a LIFO queue. maxsize is an integer that sets the upperbound limit on the number of items that can be placed in the queue. Insertion will block once this size has been reached, until queue items are consumed. If maxsize is less than or equal to zero, the queue size is infinite.
创建LIFO队列。maxsiaze <= 0, 无限制
class queue.PriorityQueue(maxsize)¶
Constructor for a priority queue. maxsize is an integer that sets the upperbound limit on the number of items that can be place


相关文档:

Performance Python Vs Java


* java强制使用OO进行应用开发,Python可以用函数式编程。函数式有时显得非常简单,代码量巨减。回想起Java动不动的N层、还有一个个对象,真的有那种心要吗?而且Python本身语言风格就简洁,再加上简洁的函数,在开发效率、Debug、测试上似乎会有优势。
* 大型复杂项目的性能更多地体现在架构、硬件拓扑结构上等。应对 ......

Python 中列出目录中所有文件的方法


Python代码
import string, os, sys   
  
dir = '/var'  
print '----------- no sub dir'  
  
files = os.listdir(dir)   
for f in files:   
   ......

用python连接mysql数据库


#
-*- encoding: gb2312 -*-
import
os, sys, string
import
MySQLdb
#
连接数据库
try
:
conn
=
MySQLdb.connect(host
=
'
localhost
'
,user
=
'
root
'
,passwd
=
'
xxxx
'
,db
=
'
test1
'
)
except
Exception, e:
print
e
sys.exit()
......

Python: python写的一个简单网络词典

闲来无事, 玩玩python...
是采用有道翻译, 然后抓取网页的.
import re, urllib
url="http://dict.youdao.com/search?le=eng&q="
print ("input q to exit")
while 1:
word = raw_input(">>>")
if word=="q":
exit()
else:
word = word.replace(' ', '+')
url += word
u ......

[Python module] select

16.1. select — Waiting for I/O completion¶
This module provides access to the select and poll functions available in most operating systems, epoll available on Linux 2.5+ and kqueue available on most BSD. Note that on Windows, it only works for sockets; on other operating systems, it al ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号