Python最近在TIOBE排行榜上被评为当今最受欢迎的编程语言,这尤其要感谢这门语言在设计、原型、测试、部署、维护方面所展现出来的广泛适用性。在本书最新的第4版中,无论是专业程序员还是需要使用Python来解决特定领域问题的人,都将学会如何将Python发挥到极致。
由公认的Python专家精心策划,新版专注于3.10版本,完全展现了Python语言取得的最新开创性成果,涵盖了最近发布的Python 3.11。
这本便捷的指南将帮助你:
学习Python如何将数据和程序表示为对象;
理解类型注解的价值和用途;
考察最新版本中出现的各种语言特性;
揭示如何地道地运用现代Python;
学习适当地搭建Python项目;
理解如何测试、调试和优化Python代码。
Preface
1. Introduction to Python
The Python Language
The Python Standard Library and Extension Modules
Python Implementations
Python Development and Versions
Python Resources
Installation
Installing Python from Binaries
Installing Python from Source Code
2. The Python Interpreter
The python Program
Python Development Environments
Running Python Programs
Running Python in the Browser
3. The Python Language
Lexical Structure
Data Types
Variables and Other References
Expressions and Operators
Numeric Operations
Sequence Operations
Set Operations
Dictionary Operations
Control Flow Statements
Functions
4. 0bject-0riented Python
Classes and Instances
Special Methods
Decorators
Metaclasses
5. Type Annotations
History
Type-Checking Utilities
Type Annotation Syntax
The typing Module
Using Type Annotations at Runtime
How to Add Type Annotations to Your Code
Summary
6. Exceptions
The try Statement
The raise Statement
The with Statement and Context Managers
Generators and Exceptions
Exception Propagation
Exception Objects
Custom Exception Classes
ExceptionGroup and except*
Error-Checking Strategies
The assert Statement
7. Modules and Packages
Module Objects
Module Loading
Packages
Distribution Utilities (distutils) and setuptools
Python Environments
8. Core Built-ins and Standard Library Modules
Built-in Types
Built-in Functions
The sys Module
The copy Module
The collections Module
The functools Module
The heapq Module
The argparse Module
The itertools Module
9. Strings and Things
Methods of String Objects
The string Module
String Formatting
Text Wrapping and Filling
The pprint Module
The reprlib Module
Unicode
10. Regular Expressions
Regular Expressions and the re Module
Optional Flags
Match Versus Search
Anchoring at String Start and End
Regular Expression Objects
Match Objects
Functions of the re Module
REs and the := Operator
The Third-Party regex Module
11. File and Text Operations
The io Module
The tempfile Module
Auxiliary Modules for File I/O
In-Memory Files: io.StringIO and io.ByteslO
Archived and Compressed Files
The os Module
The errno Module
The pathlib Module
The stat Module
The filecmp Module
The fnmatch Module
The glob Module
The shutil Module
Text Input and Output
Richer-Text I/O
Internationalization
12. Persistence and Databases
Serialization
DBM Modules
The Python Database API (DBAPI)
13. Time Operations
The time Module
The datetime Module
The zoneinfo Module
The dateutil Module
The sched Module
The calendar Module
14. Customizing Execution
Per-Site Customization
Termination Functions
Dynamic Execution and exec
Internal Types
Garbage Collection
15. Concurrency: Threads and Processes
Threads in Python
The threading Module
The queue Module
The multiprocessing Module
The concurrent.futures Module
Threaded Program Architecture
Process Environment
Running Other Programs
The mmap Module
16. Numeric Processing
Floating-Point Values
The math and cmath Modules
The statistics Module
The operator Module
Random and Pseudorandom Numbers
The fractions Module
The decimal Module
Array Processing
17. Testing, Debugging, and Optimizing
Testing
Debugging
The warnings Module
Optimization
18. Networking Basics
The Berkeley Socket Interface
Transport Layer Security
SSLContext
19. Client-Side Network Protocol Modules
Email Protocols
HTTP and URL Clients
Other Network Protocols
20. Serving HTTP
http.server
WSGI
Python Web Frameworks
21. Email, MIME, and Other Network Encodings
MIME and Email Format Handling
Encoding Binary Data as ASCII Text
22. Structured Text: HTML
The html.entities Module
The BeautifulSoup Third-P