没有合适的资源?快使用搜索试试~ 我知道了~
首页python2.6库函数参考手册
资源详情
资源评论
资源推荐

The Python Library Reference
Release 2.6
Guido van Rossum
Fred L. Drake, Jr., editor
October 02, 2008
Python Software Foundation
Email: docs@python.org


CONTENTS
1 Introduction 3
2 Built-in Functions 5
3 Non-essential Built-in Functions 21
4 Built-in Constants 23
4.1 Constants added by the site module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5 Built-in Objects 25
6 Built-in Types 27
6.1 Truth Value Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.2 Boolean Operations — and, or, not . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.3 Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.4 Numeric Types — int, float, long, complex . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.5 Iterator Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.6 Sequence Types — str, unicode, list, tuple, buffer, xrange . . . . . . . . . . . . . 32
6.7 Set Types — set, frozenset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.8 Mapping Types — dict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.9 File Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.10 Context Manager Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.11 Other Built-in Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.12 Special Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7 Built-in Exceptions 51
8 String Services 57
8.1 string — Common string operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.2 re — Regular expression operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
8.3 struct — Interpret strings as packed binary data . . . . . . . . . . . . . . . . . . . . . . . . . 80
8.4 difflib — Helpers for computing deltas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8.5 StringIO — Read and write strings as files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.6 cStringIO — Faster version of StringIO . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
8.7 textwrap — Text wrapping and filling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
8.8 codecs — Codec registry and base classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
8.9 unicodedata — Unicode Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.10 stringprep — Internet String Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
8.11 fpformat — Floating point conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9 Data Types 111
9.1 datetime — Basic date and time types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
9.2 calendar — General calendar-related functions . . . . . . . . . . . . . . . . . . . . . . . . . 132
9.3 collections — High-performance container datatypes . . . . . . . . . . . . . . . . . . . . . 134
9.4 heapq — Heap queue algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
i

9.5 bisect — Array bisection algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9.6 array — Efficient arrays of numeric values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
9.7 sets — Unordered collections of unique elements . . . . . . . . . . . . . . . . . . . . . . . . . 149
9.8 sched — Event scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.9 mutex — Mutual exclusion support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.10 queue — A synchronized queue class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
9.11 weakref — Weak references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
9.12 UserDict — Class wrapper for dictionary objects . . . . . . . . . . . . . . . . . . . . . . . . 159
9.13 UserList — Class wrapper for list objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
9.14 UserString — Class wrapper for string objects . . . . . . . . . . . . . . . . . . . . . . . . . 161
9.15 types — Names for built-in types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
9.16 new — Creation of runtime internal objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
9.17 copy — Shallow and deep copy operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
9.18 pprint — Data pretty printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
9.19 repr — Alternate repr() implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
10 Numeric and Mathematical Modules 171
10.1 numbers — Numeric abstract base classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
10.2 math — Mathematical functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
10.3 cmath — Mathematical functions for complex numbers . . . . . . . . . . . . . . . . . . . . . . 177
10.4 decimal — Decimal fixed point and floating point arithmetic . . . . . . . . . . . . . . . . . . 179
10.5 fractions — Rational numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
10.6 random — Generate pseudo-random numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
10.7 itertools — Functions creating iterators for efficient looping . . . . . . . . . . . . . . . . . 205
10.8 functools — Higher order functions and operations on callable objects . . . . . . . . . . . . 214
10.9 operator — Standard operators as functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
11 File and Directory Access 223
11.1 os.path — Common pathname manipulations . . . . . . . . . . . . . . . . . . . . . . . . . . 223
11.2 fileinput — Iterate over lines from multiple input streams . . . . . . . . . . . . . . . . . . . 226
11.3 stat — Interpreting stat() results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
11.4 statvfs — Constants used with os.statvfs() . . . . . . . . . . . . . . . . . . . . . . . . 229
11.5 filecmp — File and Directory Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
11.6 tempfile — Generate temporary files and directories . . . . . . . . . . . . . . . . . . . . . . 231
11.7 glob — Unix style pathname pattern expansion . . . . . . . . . . . . . . . . . . . . . . . . . . 233
11.8 fnmatch — Unix filename pattern matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
11.9 linecache — Random access to text lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
11.10 shutil — High-level file operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
11.11 dircache — Cached directory listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
11.12 macpath — Mac OS 9 path manipulation functions . . . . . . . . . . . . . . . . . . . . . . . . 239
12 Data Persistence 241
12.1 pickle — Python object serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
12.2 cPickle — A faster pickle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
12.3 copy_reg — Register pickle support functions . . . . . . . . . . . . . . . . . . . . . . . . 251
12.4 shelve — Python object persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
12.5 marshal — Internal Python object serialization . . . . . . . . . . . . . . . . . . . . . . . . . . 253
12.6 anydbm — Generic access to DBM-style databases . . . . . . . . . . . . . . . . . . . . . . . . 254
12.7 whichdb — Guess which DBM module created a database . . . . . . . . . . . . . . . . . . . . 255
12.8 dbm — Simple “database” interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
12.9 gdbm — GNU’s reinterpretation of dbm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
12.10 dbhash — DBM-style interface to the BSD database library . . . . . . . . . . . . . . . . . . . 257
12.11 bsddb — Interface to Berkeley DB library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
12.12 dumbdbm — Portable DBM implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
12.13 sqlite3 — DB-API 2.0 interface for SQLite databases . . . . . . . . . . . . . . . . . . . . . 262
13 Data Compression and Archiving 277
13.1 zlib — Compression compatible with gzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
13.2 gzip — Support for gzip files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
ii

13.3 bz2 — Compression compatible with bzip2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
13.4 zipfile — Work with ZIP archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
13.5 tarfile — Read and write tar archive files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
14 File Formats 295
14.1 csv — CSV File Reading and Writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
14.2 ConfigParser — Configuration file parser . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
14.3 robotparser — Parser for robots.txt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
14.4 netrc — netrc file processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
14.5 xdrlib — Encode and decode XDR data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
14.6 plistlib — Generate and parse Mac OS X .plist files . . . . . . . . . . . . . . . . . . . . 310
15 Cryptographic Services 313
15.1 hashlib — Secure hashes and message digests . . . . . . . . . . . . . . . . . . . . . . . . . . 313
15.2 hmac — Keyed-Hashing for Message Authentication . . . . . . . . . . . . . . . . . . . . . . . 314
15.3 md5 — MD5 message digest algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
15.4 sha — SHA-1 message digest algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
16 Generic Operating System Services 317
16.1 os — Miscellaneous operating system interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 317
16.2 io — Core tools for working with streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
16.3 time — Time access and conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
16.4 optparse — More powerful command line option parser . . . . . . . . . . . . . . . . . . . . 348
16.5 getopt — Parser for command line options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
16.6 logging — Logging facility for Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
16.7 getpass — Portable password input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
16.8 curses — Terminal handling for character-cell displays . . . . . . . . . . . . . . . . . . . . . 406
16.9 curses.textpad — Text input widget for curses programs . . . . . . . . . . . . . . . . . . . 421
16.10 curses.wrapper — Terminal handler for curses programs . . . . . . . . . . . . . . . . . . . 422
16.11 curses.ascii — Utilities for ASCII characters . . . . . . . . . . . . . . . . . . . . . . . . . 422
16.12 curses.panel — A panel stack extension for curses. . . . . . . . . . . . . . . . . . . . . . . 424
16.13 platform — Access to underlying platform’s identifying data. . . . . . . . . . . . . . . . . . 426
16.14 errno — Standard errno system symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
16.15 ctypes — A foreign function library for Python. . . . . . . . . . . . . . . . . . . . . . . . . . 434
17 Optional Operating System Services 465
17.1 select — Waiting for I/O completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
17.2 threading — Higher-level threading interface . . . . . . . . . . . . . . . . . . . . . . . . . . 469
17.3 thread — Multiple threads of control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
17.4 dummy_threading — Drop-in replacement for the threading module . . . . . . . . . . . 479
17.5 dummy_thread — Drop-in replacement for the thread module . . . . . . . . . . . . . . . . 479
17.6 multiprocessing — Process-based “threading” interface . . . . . . . . . . . . . . . . . . . 479
17.7 mmap — Memory-mapped file support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
17.8 readline — GNU readline interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
17.9 rlcompleter — Completion function for GNU readline . . . . . . . . . . . . . . . . . . . . 531
18 Interprocess Communication and Networking 533
18.1 subprocess — Subprocess management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
18.2 socket — Low-level networking interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
18.3 ssl — SSL wrapper for socket objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
18.4 signal — Set handlers for asynchronous events . . . . . . . . . . . . . . . . . . . . . . . . . 555
18.5 popen2 — Subprocesses with accessible I/O streams . . . . . . . . . . . . . . . . . . . . . . . 558
18.6 asyncore — Asynchronous socket handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
18.7 asynchat — Asynchronous socket command/response handler . . . . . . . . . . . . . . . . . 563
19 Internet Data Handling 567
19.1 email — An email and MIME handling package . . . . . . . . . . . . . . . . . . . . . . . . . 567
19.2 json — JSON encoder and decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594
19.3 mailcap — Mailcap file handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
iii
剩余1189页未读,继续阅读















Schurikeen
- 粉丝: 3
- 资源: 25
上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
最新资源
- ARM Cortex-A(armV7)编程手册V4.0.pdf
- ABB机器人保养总结解析.ppt
- 【超详细图解】菜鸡如何理解双向链表的python代码实现
- 常用网络命令的使用 ipconfig ping ARP FTP Netstat Route Tftp Tracert Telnet nslookup
- 基于单片机控制的DC-DC变换电路
- RS-232接口电路的ESD保护.pdf
- linux下用time(NULL)函数和localtime()获取当前时间的方法
- Openstack用户使用手册.docx
- KUKA KR 30 hA,KR 60 hA机器人产品手册.pdf
- Java programming with JNI
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

评论30