设为首页收藏本站

EPS数据狗论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 560|回复: 0

[Python] 《Python Module of the Week》

[复制链接]

93

主题

3169

金钱

3777

积分

中级用户

发表于 2018-11-7 10:29:42 | 显示全部楼层 |阅读模式

《Python Module of the Week》
pdf
1 Data Persistence and Exchange 3
1.1 Serializing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Storing Serialized Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Data Exchange Through Standard Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 In-Memory Data Structures 5
2.1 array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.5 Decoding Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6 Custom Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 File Access 7
3.1 Filenames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Meta-data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Reading Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.4 Temporary Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.5 Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4 Text Processing Tools 9
4.1 string module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Text Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.3 Text Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.4 Comparing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5 Built-in Objects 11
5.1 exceptions – Built-in error classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6 String Services 23
6.1 codecs – String encoding and decoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.2 difflib – Compare sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.3 string – Working with text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.4 StringIO and cStringIO – Work with text buffers using file-like API . . . . . . . . . . . . . . . . . . 54
6.5 re – Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.6 struct – Working with Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.7 textwrap – Formatting text paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7 Data Types 97
7.1 array – Sequence of fixed-type data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.2 datetime – Date/time value manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.3 calendar – Work with dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
7.4 collections – Container data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
7.5 heapq – In-place heap sort algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
7.6 bisect – Maintain lists in sorted order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
7.7 sched – Generic event scheduler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
7.8 Queue – A thread-safe FIFO implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
7.9 weakref – Garbage-collectable references to objects . . . . . . . . . . . . . . . . . . . . . . . . . . 135
7.10 copy – Duplicate objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
7.11 pprint – Pretty-print data structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
8 Numeric and Mathematical Modules 153
8.1 decimal – Fixed and floating point math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
8.2 fractions – Rational Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
8.3 functools – Tools for Manipulating Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
8.4 itertools – Iterator functions for efficient looping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
8.5 math – Mathematical functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
8.6 operator – Functional interface to built-in operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
8.7 random – Pseudorandom number generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
9 Internet Data Handling 213
9.1 base64 – Encode binary data into ASCII characters . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
9.2 json – JavaScript Object Notation Serializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
9.3 mailbox – Access and manipulate email archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
9.4 mhlib – Work with MH mailboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
10 File Formats 233
10.1 csv – Comma-separated value files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
10.2 ConfigParser – Work with configuration files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
10.3 robotparser – Internet spider access control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
11 Cryptographic Services 255
11.1 hashlib – Cryptographic hashes and message digests . . . . . . . . . . . . . . . . . . . . . . . . . . 255
11.2 hmac – Cryptographic signature and verification of messages. . . . . . . . . . . . . . . . . . . . . . 258
12 File and Directory Access 263
12.1 os.path – Platform-independent manipulation of file names. . . . . . . . . . . . . . . . . . . . . . . 263
12.2 fileinput – Process lines from input streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
12.3 filecmp – Compare files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
12.4 tempfile – Create temporary filesystem resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
12.5 glob – Filename pattern matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
12.6 fnmatch – Compare filenames against Unix-style glob patterns. . . . . . . . . . . . . . . . . . . . . 285
12.7 linecache – Read text files efficiently . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
12.8 shutil – High-level file operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
12.9 dircache – Cache directory listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
13 Data Compression and Archiving 299
13.1 bz2 – bzip2 compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
13.2 gzip – Read and write GNU zip files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
13.3 tarfile – Tar archive access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
13.4 zipfile – Read and write ZIP archive files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
13.5 zlib – Low-level access to GNU zlib compression library . . . . . . . . . . . . . . . . . . . . . . . . 326
14 Data Persistence 333
14.1 anydbm – Access to DBM-style databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
14.2 dbhash – DBM-style API for the BSD database library . . . . . . . . . . . . . . . . . . . . . . . . . 335
14.3 dbm – Simple database interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
14.4 dumbdbm – Portable DBM Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
14.5 gdbm – GNU’s version of the dbm library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
14.6 pickle and cPickle – Python object serialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
14.7 shelve – Persistent storage of arbitrary Python objects . . . . . . . . . . . . . . . . . . . . . . . . . 344
14.8 whichdb – Identify DBM-style database formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
14.9 sqlite3 – Embedded Relational Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
15 Generic Operating System Services 377
15.1 os – Portable access to operating system specific features. . . . . . . . . . . . . . . . . . . . . . . . 377
15.2 time – Functions for manipulating clock time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
15.3 getopt – Command line option parsing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
15.4 optparse – Command line option parser to replace getopt. . . . . . . . . . . . . . . . . . . . . . . . 402
15.5 argparse – Command line option and argument parsing. . . . . . . . . . . . . . . . . . . . . . . . . 414
15.6 logging – Report status, error, and informational messages. . . . . . . . . . . . . . . . . . . . . . . . 433
15.7 getpass – Prompt the user for a password without echoing. . . . . . . . . . . . . . . . . . . . . . . . 437
15.8 platform – Access system version information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
16 Optional Operating System Services 443
16.1 threading – Manage concurrent threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
16.2 mmap – Memory-map files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
16.3 multiprocessing – Manage processes like threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
16.4 readline – Interface to the GNU readline library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
16.5 rlcompleter – Adds tab-completion to the interactive interpreter . . . . . . . . . . . . . . . . . . . . 493
17 Unix-specific Services 495
17.1 commands – Run external shell commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
17.2 grp – Unix Group Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
17.3 pipes – Unix shell command pipeline templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
17.4 pwd – Unix Password Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
17.5 resource – System resource management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
18 Interprocess Communication and Networking 513
18.1 asynchat – Asynchronous protocol handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
18.2 asyncore – Asynchronous I/O handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
18.3 signal – Receive notification of asynchronous system events . . . . . . . . . . . . . . . . . . . . . . 530
18.4 subprocess – Work with additional processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
19 Internet Protocols and Support 547
19.1 BaseHTTPServer – base classes for implementing web servers . . . . . . . . . . . . . . . . . . . . . 547
19.2 cgitb – Detailed traceback reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
19.3 Cookie – HTTP Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
19.4 imaplib - IMAP4 client library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
19.5 SimpleXMLRPCServer – Implements an XML-RPC server. . . . . . . . . . . . . . . . . . . . . . . 584
19.6 smtpd – Sample SMTP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
19.7 smtplib – Simple Mail Transfer Protocol client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
19.8 socket – Network Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
19.9 select – Wait for I/O Efficiently . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622
19.10 SocketServer – Creating network servers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
19.11 urllib – simple interface for network resource access . . . . . . . . . . . . . . . . . . . . . . . . . . 639
19.12 urllib2 – Library for opening URLs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645
19.13 urlparse – Split URL into component pieces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
19.14 uuid – Universally unique identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
19.15 webbrowser – Displays web pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
19.16 xmlrpclib – Client-side library for XML-RPC communication . . . . . . . . . . . . . . . . . . . . . 663
20 Structured Markup Processing Tools 671
20.1 xml.etree.ElementTree – XML Manipulation API . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
21 Internationalization 691
21.1 gettext – Message Catalogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
21.2 locale – POSIX cultural localization API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697
22 Program Frameworks 705
22.1 cmd – Create line-oriented command processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705
22.2 shlex – Lexical analysis of shell-style syntaxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
23 Development Tools 723
23.1 doctest – Testing through documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
23.2 pydoc – Online help for Python modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
23.3 unittest – Automated testing framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
23.4 pdb – Interactive Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
24 Debugging and Profiling 777
24.1 profile, cProfile, and pstats – Performance analysis of Python programs. . . . . . . . . . . . . . . . . 777
24.2 timeit – Time the execution of small bits of Python code. . . . . . . . . . . . . . . . . . . . . . . . . 782
24.3 trace – Follow Python statements as they are executed . . . . . . . . . . . . . . . . . . . . . . . . . 787
25 Python Runtime Services 795
25.1 abc – Abstract Base Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 795
25.2 atexit – Call functions when a program is closing down . . . . . . . . . . . . . . . . . . . . . . . . . 802
25.3 contextlib – Context manager utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805
25.4 gc – Garbage Collector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810
25.5 inspect – Inspect live objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826
25.6 site – Site-wide configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
25.7 sys – System-specific Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 842
25.8 sysconfig – Interpreter Compile-time Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 881
25.9 traceback – Extract, format, and print exceptions and stack traces. . . . . . . . . . . . . . . . . . . . 885
25.10 warnings – Non-fatal alerts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 890
26 Importing Modules 897
26.1 imp – Interface to module import mechanism. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897
26.2 pkgutil – Package Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 900
26.3 zipimport – Load Python code from inside ZIP archives . . . . . . . . . . . . . . . . . . . . . . . . 907
27 Miscelaneous 913
27.1 EasyDialogs – Carbon dialogs for Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 913
27.2 plistlib – Manipulate OS X property list files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 926
28 History 931
Python Module Index 943
Index 945

Python Module of the Week.pdf

3.51 MB, 下载次数: 0

售价: 4 金钱  [记录]  [购买]

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

客服中心
关闭
在线时间:
周一~周五
8:30-17:30
QQ群:
653541906
联系电话:
010-85786021-8017
在线咨询
客服中心

意见反馈|网站地图|手机版|小黑屋|EPS数据狗论坛 ( 京ICP备09019565号-3 )   

Powered by BFIT! X3.4

© 2008-2028 BFIT Inc.

快速回复 返回顶部 返回列表