[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 also works for other file types (in particular, on Unix, it works on pipes). It cannot be used on regular files to determine whether a file has grown since it was last read.
The module defines the following:
这个模块提供大多数操作系统的select和poll功能。 epoll在Linux2.5+可用,kqueue则用于BSD。在winodws系统上,它仅用于socket,在其他系统下,它也可以用于其他类型(特别在 Unix 下,它还可以用于 管道)。它不能用来确定自从上次读取以后是否普通文件有所增长。
exception select. error ¶ The exception raised when an error occurs. The accompanying value is a pair containing the numeric error code from errno and the corresponding string, as would be printed by the C function perror .
在发生错误将引发异常。accompanying 值包含错误代码和错误描述文本,用于使用 C 程序 perror() 打印。
select. epoll ( [ sizehint=-1 ] ) ¶ (Only supported on Linux 2.5.44 and newer.) Returns an edge polling object, which can be used as Edge or Level Triggered interface for I/O events; see section Edge and Level Trigger Polling (epoll) Objects below for the methods supported by epolling objects.
仅仅在Linux2.5.44以上支持。
select. poll ( ) ¶ (Not supported by all operating systems.) Returns a polling object, which supports registering and unregistering file descriptors, and then polling them for I/O events; see section Polling Objects below for the methods supported by polling objects.
所有系统不支持。
select. kqueue ( ) ¶ (Only supported on BSD.) Returns a kernel queue object object; see section Kqueue Objects below for the methods supported by kqueue objects.
仅仅支持BSD。
select. kevent ( ident , filter=KQ_FILTER_READ , flags=KQ_ADD , fflags=0 , data=0 , udata=0 ) ¶ (Only suppor
相关文档:
下载了很多压缩文件,就写了一个脚本
在Python中使用winrar命令,所以一般压缩文件都支持
有些压缩文件Python中还没有相应的库
你得先把winrar添加到path环境变量中
把代码保存为rar.py
在dos下使用,如:rar.py "D:\A B\C" mkdir
#rar.py
#decompress with winrar
#arguments :filename directory opt
# op ......
综述
多线程是程序设计中的一个重要方面,尤其是在服务器Deamon程序方面。无论何种系统,线程调度的开销都比传统的进程要快得多。
Python可以方便地支持多线程。可以快速创建线程、互斥锁、信号量等等元素,支持线程读写同步互斥。美中不足的是,Python的运行在Python
虚拟机上,创建的多线程可 ......
type相关:
所有自定义类A
其实例,如 a = A()
使用type运算符返回的都是<type, 'instance'>
而基本类型
比如 b = 3
type(b),结果是<type, 'int'>
python的type不像C++中的typeid那样,可以显示类名。
(注:对于没有virtual函数的类而言,typeid是编译时期的事情(也就是静态类型);对于有virtual函 ......
#
-*- 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()
......