Python 3:标准库介绍


  • 参照Python3.5官方手册,写一下python SDL库的笔记,持续更新

1 Introduction

  • 简要介绍Python标准库

2 Built-in Functions

  • 内置函数

3 Built-in Constants

  • 内置常量
3.1 Constants added by the site module

4 Built-in Types

  • 内置类型
4.1 Truth Value Testing
4.2 Boolean Operations — and, or, not
4.3 Comparisons
4.4 Numeric Types — int, float, complex
4.5 Iterator Types
4.6 Sequence Types — list, tuple, range
4.7 Text Sequence Type — str
4.8 Binary Sequence Types — bytes, bytearray, memoryview
4.9 Set Types — set, frozenset
4.10 Mapping Types — dict

5 Built-in Exceptions

  • 内置异常
5.1 Base classes
5.2 Concrete exceptions
5.3 Warnings
5.4 Exception hierarchy

6 Text Processing Services

  • 文本处理服务
6.1 string — Common string operations
6.2 re — Regular expression operations
6.3 difflib — Helpers for computing deltas
6.4 textwrap — Text wrapping and filling
6.5 unicodedata — Unicode Database
6.6 stringprep — Internet String Preparation
6.7 readline — GNU readline interface
6.8 rlcompleter — Completion function for GNU readline

7 Binary Data Services

  • 二进制数据处理服务
7.1 struct — Interpret bytes as packed binary data
7.2 codecs — Codec registry and base classes

8 Data Types

  • 数据类型
8.1 datetime — Basic date and time types
8.2 calendar — General calendar-related functions
8.3 collections — Container datatypes
8.4 collectionsabc — Abstract Base Classes for Containers
8.5 heapq — Heap queue algorithm
8.6 bisect — Array bisection algorithm
8.7 array — Efficient arrays of numeric values
8.8 weakref — Weak references
8.9 types — Dynamic type creation and names for built-in types
8.10 copy — Shallow and deep copy operations
8.11 pprint — Data pretty printer
8.12 reprlib — Alternate repr() implementation
8.13 enum — Support for enumerations

9 Numeric and Mathematical Modules

  • 数值和数学模型
9.1 numbers — Numeric abstract base classes
9.2 math — Mathematical functions
9.3 cmath — Mathematical functions for complex numbers
9.4 decimal — Decimal fixed point and floating point arithmetic
9.5 fractions — Rational numbers
9.6 random — Generate pseudo-random numbers
9.7 statistics — Mathematical statistics functions

10 Functional Programming Modules

  • 函数式编程模块
10.1 itertools — Functions creating iterators for efficient looping
10.2 functools — Higher-order functions and operations on callable objects
10.3 operator — Standard operators as functions

11 File and Directory Access

  • 文件和目录存取
11.1 pathlib — Object-oriented filesystem paths
11.2 ospath — Common pathname manipulations
11.3 fileinput — Iterate over lines from multiple input streams
11.4 stat — Interpreting stat() results
11.5 filecmp — File and Directory Comparisons
11.6 tempfile — Generate temporary files and directories
11.7 glob — Unix style pathname pattern expansion
11.8 fnmatch — Unix filename pattern matching
11.9 linecache — Random access to text lines
11.10 shutil — High-level file operations
11.11 macpath — Mac OS 9 path manipulation functions

12 Data Persistence

  • 数据永久存储
12.1 pickle — Python object serialization
12.2 copyreg — Register pickle support functions
12.3 shelve — Python object persistence
12.4 marshal — Internal Python object serialization
12.5 dbm — Interfaces to Unix “databases”
12.6 sqlite3 — DB-API 20 interface for SQLite databases

13 Data Compression and Archiving

  • 数据压缩和归档
13.1 zlib — Compression compatible with gzip
13.2 gzip — Support for gzip files
13.3 bz2 — Support for bzip2 compression
13.4 lzma — Compression using the LZMA algorithm
13.5 zipfile — Work with ZIP archives
13.6 tarfile — Read and write tar archive files

14 File Formats

  • 文件格式
14.1 csv — CSV File Reading and Writing
14.2 configparser — Configuration file parser
14.3 netrc — netrc file processing
14.4 xdrlib — Encode and decode XDR data
14.5 plistlib — Generate and parse Mac OS X plist files

15 Cryptographic Services

  • 加密服务
15.1 hashlib — Secure hashes and message digests
15.2 hmac — Keyed-Hashing for Message Authentication

16 Generic Operating System Services

  • 通用操作系统服务
16.1 os — Miscellaneous operating system interfaces
16.2 io — Core tools for working with streams
16.3 time — Time access and conversions
16.4 argparse — Parser for command-line options, arguments and sub-commands
16.5 getopt — C-style parser for command line options
16.6 logging — Logging facility for Python
16.7 loggingconfig — Logging configuration
16.8 logginghandlers — Logging handlers
16.9 getpass — Portable password input
16.10 curses — Terminal handling for character-cell displays
16.11 cursestextpad — Text input widget for curses programs
16.12 cursesascii — Utilities for ASCII characters
16.13 cursespanel — A panel stack extension for curses
16.14 platform — Access to underlying platform’s identifying data
16.15 errno — Standard errno system symbols
16.16 ctypes — A foreign function library for Python

17 Concurrent Execution

  • 并行执行
17.1 threading — Thread-based parallelism
17.2 multiprocessing — Process-based parallelism
17.3 The concurrent package
17.4 concurrentfutures — Launching parallel tasks
17.5 subprocess — Subprocess management
17.6 sched — Event scheduler
17.7 queue — A synchronized queue class
17.8 dummy_threading — Drop-in replacement for the threading module
17.9 _thread — Low-level threading API
17.10 _dummy_thread — Drop-in replacement for the _thread module

18 Interprocess Communication and Networking

  • 进程间通信和网络
18.1 socket — Low-level networking interface
18.2 ssl — TLS/SSL wrapper for socket objects
18.3 select — Waiting for I/O completion
18.4 selectors — High-level I/O multiplexing
18.5 asyncio — Asynchronous I/O, event loop, coroutines and tasks
18.6 asyncore — Asynchronous socket handler
18.7 asynchat — Asynchronous socket command/response handler
18.8 signal — Set handlers for asynchronous events
18.9 mmap — Memory-mapped file support

19 Internet Data Handling

  • 网络数据处理
19.1 email — An email and MIME handling package
19.2 json — JSON encoder and decoder
19.3 mailcap — Mailcap file handling
19.4 mailbox — Manipulate mailboxes in various formats
19.5 mimetypes — Map filenames to MIME types
19.6 base64 — Base16, Base32, Base64, Base85 Data Encodings
19.7 binhex — Encode and decode binhex4 files
19.8 binascii — Convert between binary and ASCII
19.9 quopri — Encode and decode MIME quoted-printable data
19.10 uu — Encode and decode uuencode files

20 Structured Markup Processing Tools

  • 结构化标记处理工具
20.1 html — HyperText Markup Language support
20.2 htmlparser — Simple HTML and XHTML parser
20.3 htmlentities — Definitions of HTML general entities
20.4 XML Processing Modules
20.5 xmletreeElementTree — The ElementTree XML API
20.6 xmldom — The Document Object Model API
20.7 xmldomminidom — Minimal DOM implementation
20.8 xmldompulldom — Support for building partial DOM trees
20.9 xmlsax — Support for SAX2 parsers
20.10 xmlsaxhandler — Base classes for SAX handlers
20.11 xmlsaxsaxutils — SAX Utilities
20.12 xmlsaxxmlreader — Interface for XML parsers
20.13 xmlparsersexpat — Fast XML parsing using Expat

21 Internet Protocols and Support

  • 互联网协议及支持
21.1 webbrowser — Convenient Web-browser controller
21.2 cgi — Common Gateway Interface support
21.3 cgitb — Traceback manager for CGI scripts
21.4 wsgiref — WSGI Utilities and Reference Implementation
21.5 urllib — URL handling modules
21.6 urllibrequest — Extensible library for opening URLs
21.7 urllibresponse — Response classes used by urllib
21.8 urllibparse — Parse URLs into components
21.9 urlliberror — Exception classes raised by urllibrequest
21.10 urllibrobotparser — Parser for robotstxt
21.11 http — HTTP modules
21.12 httpclient — HTTP protocol client
21.13 ftplib — FTP protocol client
21.14 poplib — POP3 protocol client
21.15 imaplib — IMAP4 protocol client
21.16 nntplib — NNTP protocol client
21.17 smtplib — SMTP protocol client
21.18 smtpd — SMTP Server
21.19 telnetlib — Telnet client
21.20 uuid — UUID objects according to RFC 4122
21.21 socketserver — A framework for network servers
21.22 httpserver — HTTP servers
21.23 httpcookies — HTTP state management
21.24 httpcookiejar — Cookie handling for HTTP clients
21.25 xmlrpc — XMLRPC server and client modules
21.26 xmlrpcclient — XML-RPC client access
21.27 xmlrpcserver — Basic XML-RPC servers
21.28 ipaddress — IPv4/IPv6 manipulation library

22 Multimedia Services

  • 多媒体服务
22.1 audioop — Manipulate raw audio data
22.2 aifc — Read and write AIFF and AIFC files
22.3 sunau — Read and write Sun AU files
22.4 wave — Read and write WAV files
22.5 chunk — Read IFF chunked data
22.6 colorsys — Conversions between color systems
22.7 imghdr — Determine the type of an image
22.8 sndhdr — Determine type of sound file
22.9 ossaudiodev — Access to OSS-compatible audio devices

23 Internationalization

  • 国际化
23.1 gettext — Multilingual internationalization services
23.2 locale — Internationalization services

24 Program Frameworks

  • 程序框架
24.1 turtle — Turtle graphics
24.2 cmd — Support for line-oriented command interpreters
24.3 shlex — Simple lexical analysis

25 Graphical User Interfaces with Tk

  • 图形用户接口
25.1 tkinter — Python interface to Tcl/Tk
25.2 tkinterttk — Tk themed widgets
25.3 tkintertix — Extension widgets for Tk
25.4 tkinterscrolledtext — Scrolled Text Widget
25.5 IDLE
25.6 Other Graphical User Interface Packages

26 Development Tools

  • 开发工具
26.1 typing — Support for type hints
26.2 pydoc — Documentation generator and online help system
26.3 doctest — Test interactive Python examples
26.4 unittest — Unit testing framework
26.5 unittestmock — mock object library
26.6 unittestmock — getting started
26.7 2to3 - Automated Python 2 to 3 code translation
26.8 test — Regression tests package for Python
26.9 testsupport — Utilities for the Python test suite

27 Debugging and Profiling

  • 调试和性能分析
27.1 bdb — Debugger framework
27.2 faulthandler — Dump the Python traceback
27.3 pdb — The Python Debugger
27.4 The Python Profilers
27.5 timeit — Measure execution time of small code snippets
27.6 trace — Trace or track Python statement execution
27.7 tracemalloc — Trace memory allocations

28 Software Packaging and Distribution

  • 软件打包和分发
28.1 distutils — Building and installing Python modules
28.2 ensurepip — Bootstrapping the pip installer
28.3 venv — Creation of virtual environments
28.4 zipapp — Manage executable python zip archives

29 Python Runtime Services

  • 运行时服务
29.1 sys — System-specific parameters and functions
29.2 sysconfig — Provide access to Python’s configuration information
29.3 builtins — Built-in objects
29.4 __main__ — Top-level script environment
29.5 warnings — Warning control
29.6 contextlib — Utilities for with-statement contexts
29.7 abc — Abstract Base Classes
29.8 atexit — Exit handlers
29.9 traceback — Print or retrieve a stack traceback
29.10 __future__ — Future statement definitions
29.11 gc — Garbage Collector interface
29.12 inspect — Inspect live objects
29.13 site — Site-specific configuration hook
29.14 fpectl — Floating point exception control

30 Custom Python Interpreters

  • 自定义Python解释器
30.1 code — Interpreter base classes
30.2 codeop — Compile Python code

31 Importing Modules

  • 导入模块
31.1 zipimport — Import modules from Zip archives
31.2 pkgutil — Package extension utility
31.3 modulefinder — Find modules used by a script
31.4 runpy — Locating and executing Python modules
31.5 importlib — The implementation of import

32 Python Language Services

  • Python语言服务
32.1 parser — Access Python parse trees
32.2 ast — Abstract Syntax Trees
32.3 symtable — Access to the compiler’s symbol tables
32.4 symbol — Constants used with Python parse trees
32.5 token — Constants used with Python parse trees
32.6 keyword — Testing for Python keywords
32.7 tokenize — Tokenizer for Python source
32.8 tabnanny — Detection of ambiguous indentation
32.9 pyclbr — Python class browser support
32.10 py_compile — Compile Python source files
32.11 compileall — Byte-compile Python libraries
32.12 dis — Disassembler for Python bytecode
32.13 pickletools — Tools for pickle developers

33 Miscellaneous Services

  • 杂项服务
33.1 formatter — Generic output formatting

34 MS Windows Specific Services

  • Windows相关服务
34.1 msilib — Read and write Microsoft Installer files
34.2 msvcrt — Useful routines from the MS VC++ runtime
34.3 winreg — Windows registry access
34.4 winsound— Sound-playing interface for Windows

35 Unix Specific Services

  • Unix相关服务
35.1 posix — The most common POSIX system calls
35.2 pwd — The password database
35.3 spwd — The shadow password database
35.4 grp — The group database
35.5 crypt — Function to check Unix passwords
35.6 termios — POSIX style tty control
35.7 tty — Terminal control functions
35.8 pty — Pseudo-terminal utilities
35.9 fcntl — The fcntl and ioctl system calls
35.10 pipes — Interface to shell pipelines
35.11 resource — Resource usage information
35.12 nis — Interface to Sun’s NIS (Yellow Pages)
35.13 syslog — Unix syslog library routines

36 Superseded Modules

  • 取代模块
36.1 optparse — Parser for command line options
36.2 imp — Access the import internals

37 Undocumented Modules

  • 未归档模块
37.1 Platform specific modules
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,864评论 6 494
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,175评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,401评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,170评论 1 286
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,276评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,364评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,401评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,179评论 0 269
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,604评论 1 306
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,902评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,070评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,751评论 4 337
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,380评论 3 319
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,077评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,312评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,924评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,957评论 2 351

推荐阅读更多精彩内容