Introduction介绍

The “Python library” contains several different kinds of components.“Python库”包含几种不同类型的组件。

It contains data types that would normally be considered part of the “core” of a language, such as numbers and lists. 它包含通常被视为语言“核心”一部分的数据类型,如数字和列表。For these types, the Python language core defines the form of literals and places some constraints on their semantics, but does not fully define the semantics. 对于这些类型,Python语言核心定义了文字的形式,并对其语义进行了一些约束,但没有完全定义语义。(On the other hand, the language core does define syntactic properties like the spelling and priorities of operators.)(另一方面,语言核心确实定义了语法属性,如运算符的拼写和优先级。)

The library also contains built-in functions and exceptions — objects that can be used by all Python code without the need of an import statement. 该库还包含内置函数和异常—所有Python代码都可以使用这些对象,而无需import语句。Some of these are defined by the core language, but many are not essential for the core semantics and are only described here.其中一些是由核心语言定义的,但许多不是核心语义所必需的,只在这里描述。

The bulk of the library, however, consists of a collection of modules. 然而,库的大部分由模块集合组成。There are many ways to dissect this collection. 有许多方法可以剖析此集合。Some modules are written in C and built in to the Python interpreter; others are written in Python and imported in source form. 一些模块是用C语言编写的,内置在Python解释器中;其他的是用Python编写的,并以源代码形式导入。Some modules provide interfaces that are highly specific to Python, like printing a stack trace; some provide interfaces that are specific to particular operating systems, such as access to specific hardware; others provide interfaces that are specific to a particular application domain, like the World Wide Web. 一些模块提供了非常特定于Python的接口,例如打印堆栈跟踪;有些提供特定于特定操作系统的接口,例如访问特定硬件;另一些提供特定于特定应用程序域的接口,如万维网。Some modules are available in all versions and ports of Python; others are only available when the underlying system supports or requires them; yet others are available only when a particular configuration option was chosen at the time when Python was compiled and installed.有些模块在Python的所有版本和端口中都可用;其他仅在底层系统支持或需要时可用;然而,只有在编译和安装Python时选择了特定的配置选项时,其他选项才可用。

This manual is organized “from the inside out:” it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapters of related modules.本手册是“由内而外”组织的,它首先描述内置功能、数据类型和异常,最后是模块,分组在相关模块的章节中。

This means that if you start reading this manual from the start, and skip to the next chapter when you get bored, you will get a reasonable overview of the available modules and application areas that are supported by the Python library. 这意味着,如果您从一开始就开始阅读本手册,并且在感到厌烦时跳到下一章,您将对Python库支持的可用模块和应用程序区域有一个合理的概述。Of course, you don’t have to read it like a novel — you can also browse the table of contents (in front of the manual), or look for a specific function, module or term in the index (in the back). 当然,你不必像读小说一样阅读它——你也可以浏览目录(在手册的前面),或者在索引中查找特定的函数、模块或术语(在后面)。And finally, if you enjoy learning about random subjects, you choose a random page number (see module random) and read a section or two. 最后,如果你喜欢学习随机主题,你可以选择一个随机页码(请参阅random模块)并阅读一两节。Regardless of the order in which you read the sections of this manual, it helps to start with chapter Built-in Functions, as the remainder of the manual assumes familiarity with this material.无论您阅读本手册各节的顺序如何,从章节内置函数开始都会有所帮助,因为本手册的其余部分假定您熟悉本材料。

Let the show begin!让表演开始吧!

Notes on availability可用性说明

  • An “Availability: Unix” note means that this function is commonly found on Unix systems. “Availability:Unix”注释表示此功能通常在Unix系统上找到。It does not make any claims about its existence on a specific operating system.它不会对其在特定操作系统上的存在发表任何声明。

  • If not separately noted, all functions that claim “Availability: Unix” are supported on macOS, which builds on a Unix core.如果没有单独说明,所有声称“可用性:Unix”的功能都在构建在Unix核心上的macOS上受支持。