The Python Standard Library cover

The Python Standard Library

Rating 4.2
Chapters
21
ISBN
9787111378105

Tags

Summary

The Python Standard Library is a representative work by the well-known Python community blogger Doug Hellmann; the Chinese edition was translated by Liu Chi and others and published by China Machine Press in the "HZ Books Programmer's Library" series. The book was adapted from the author's "Python Module of the Week" blog series and systematically explains more than a hundred commonly used modules in the Python 2.7 standard library in the format of "one module per section, a runnable sample code, and its output." The book has 19 chapters, covering text processing (string, textwrap, re, difflib), data structures (collections, array, heapq, bisect, Queue, struct, weakref, copy, pprint), algorithm tools (functools, itertools, operator, contextlib), date and time (time, datetime, calendar), mathematical operations (decimal, fractions, random, math, statistics), the file system (os.path, glob, fnmatch, linecache, tempfile, shutil, filecmp, mmap, codecs, io), data persistence and exchange (pickle, shelve, dbm, sqlite3, xml.etree.ElementTree, csv), compression and archiving (zlib, gzip, bz2, tarfile, zipfile), cryptography (hashlib, hmac), processes, threads, and concurrency (subprocess, signal, threading, multiprocessing, concurrent.futures), network communication (socket, select, selectors, socketserver, ipaddress), and internet-related topics (urllib, base64, http.server, json, uuid, and so on), as well as application building blocks, internationalization, development tools, runtime features, and language tools. Each section not only explains how to use a module but also uses an independent small example to explain its mechanics and boundaries, with links to further resources at the end, so the book suits both systematic chapter-by-chapter study and quick desk reference. Note that the book targets Python 2.7; the author later published The Python 3 Standard Library for Python 3, and some examples in The Python Standard Library need adjustment under Python 3, so readers should consult the official documentation alongside it.

Editor's review

很多 Python 书教你写业务代码,却很少有人把“语言自带的那一整箱工具”摊开给你看。《Python标准库》填的正是这个空档:它不讲语法,而是把标准库中一百多个模块按用途归类,一节一个模块,用短小、可复现的示例说明“它怎么工作”“为什么要这样设计”。 它的优势有三点。第一是实战感强,所有例子都来自作者维护多年的 PyMOTW 博客,经社区反复打磨,几乎每一段都能直接拿来改;第二是覆盖完整,从文本、数据结构、算法、时间、数学,到文件系统、序列化、压缩、加密、并发、网络和互联网工具,一本通读下来,你会发现自己少写了很多重复的轮子代码;第三是结构清爽,每节篇幅短、界限清楚,非常适合按需跳读、当作案头速查手册使用。 需要如实提醒:本书面向 Python 2.7,虽然绝大多数 API 思想在 Python 3 中依然成立,但局部示例需要改写,作者后来也专门出了适配 Python 3 的《Python 3标准库》。如果你主要使用 Python 3,建议以新版为主,把这本书当作理解模块设计思路的补充读物,两者对照着看收获最大。

Who it's for

A good fit for

  • 已掌握 Python 基础语法、想系统熟悉标准库的中级程序员
  • 经常写脚本处理文本、文件、数据格式转换的运维与数据工作者
  • 希望少装第三方库、用内置模块解决常见任务的后端开发者
  • 准备面试或想系统梳理 Python 常用模块知识点的学习者

Not a good fit for

  • 完全没有编程基础的零起点读者,书中不讲解语言入门知识
  • 主要使用 Python 3、只想找现成可复制代码的读者,宜选《Python 3标准库》
  • 寻找框架级实践(如 Web 框架、机器学习)的项目型读者

Reading tips

  1. 第一遍按章通读目录与每节开头,先建立“哪个模块解决哪类问题”的地图,再挑常用章节精读。
  2. 随手开一个代码文件,把示例敲一遍并改动参数观察输出差异,比只读更能理解模块行为。
  3. 把本书当手册用:遇到文本解析、文件处理、并发或网络需求时,按功能定位对应章节再细读。
  4. 若使用 Python 3,请对照官方文档核对 API 变化,并可搭配《Python 3标准库》同步学习。

About the publisher

China Machine Press China · Founded in 1950

In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.

Contents

  1. Chapter 1 Text (string, textwrap, re, difflib)
  2. Chapter 2 Data Structures (collections, array, heapq, bisect, Queue, struct, weakref, copy, pprint)
  3. Chapter 3 Algorithms (functools, itertools, operator, contextlib)
  4. Chapter 4 Dates and Times (time, datetime, calendar)
  5. Chapter 5 Mathematical Operations (decimal, fractions, random, math, statistics)
  6. Chapter 6 The File System (os.path, glob, fnmatch, linecache, tempfile, shutil, filecmp, mmap, codecs, io)
  7. Chapter 7 Data Persistence and Exchange (pickle, shelve, dbm, sqlite3, xml.etree.ElementTree, csv)
  8. Chapter 8 Data Compression and Archiving (zlib, gzip, bz2, tarfile, zipfile)
  9. Chapter 9 Cryptography (hashlib, hmac)
  10. Chapter 10 Concurrency with Processes, Threads, and Coroutines (subprocess, signal, threading, multiprocessing, concurrent.futures)
  11. Chapter 11 Networking (ipaddress, socket, select, selectors, socketserver)
  12. Chapter 12 The Internet (urllib, base64, http.server, http.cookies, uuid, json, xmlrpc, and others)
  13. Chapter 13 Email (modules for parsing and sending email)
  14. Chapter 14 Application Building Blocks
  15. Chapter 15 Internationalization and Localization
  16. Chapter 16 Developer Tools
  17. Chapter 17 Runtime Features
  18. Chapter 18 Language Tools
  19. Chapter 19 Modules and Packages
  20. Appendix A Porting Notes
  21. Appendix B Beyond the Standard Library

FAQ

这本书讲的是 Python 2 还是 Python 3?
《Python标准库》(2012 年,ISBN 9787111378105)面向 Python 2.7,示例基于 2.x 编写。作者后来另有《Python 3标准库》(苏金国等译,机械工业出版社,ISBN 9787111608950)以适配 Python 3,如果主要使用 Python 3,建议选后者。
零基础能直接读这本书吗?
不太适合。本书定位为中等程度 Python 程序员的参考手册,默认读者熟悉语法与常用编程概念,几乎不讲解语言入门知识。建议先用入门书打好基础,再来系统学习标准库。
它和 Python 官方文档有什么区别?
官方文档偏重 API 规格罗列,本书则以独立小示例演示模块的实际用法与行为,并补充“为什么要这样工作”的解释,读起来更像教程与案例合集,适合在查文档之前先形成直觉。
书里的示例代码能直接用在项目里吗?
多数示例是独立、可直接运行的短程序,思路和写法可以直接借鉴;但代码为演示而刻意简化,未处理异常、边界和安全问题,投入生产前仍需补充错误处理与测试。
这本书有必要逐页读完吗?
不必。全书 19 章约一千页,章节之间相互独立,更推荐按需阅读:先浏览目录掌握模块分布,再针对当前任务精读对应章节,其余作为速查资料保留。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

Top rated in the same category