.. _library-intro: ************ 介绍 ************ .. 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. (On the other hand, the language core does define syntactic properties like the spelling and priorities of operators.) 包括组成一个编程语言最核心部分的数据类型,比如数字、列表。对于这些数据类型,Python 语言\ 核心定义了它们的表达形式和一些语义规范,但并没有定义全部的语义规范。(比如,语言核心定\ 义了语义规范,像拼写计算符的优先级。) .. The library also contains built-in functions and exceptions --- objects that can be used by all Python code without the need of an :keyword:`import` statement. Some of these are defined by the core language, but many are not essential for the core semantics and are only described here. Python 库还包括了内置函数和表达式,你可以在所有的 Python 代码中使用这些内置函数和表达式\ 而不需要使用 :keyword:`import` 语句。一些内置函数和表达式是被 Python 本身核心代码所使用的,\ 但是很多并不是核心语义所必须的,它们的存在只是为了方便使用。 .. 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. 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. 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 库的主要由很多模块构成的。我们可以从很多方面去剖析这些模块。一些模块使用 C 语言写成\ 并且内置到 Python 解释器中;另外的是由 Python 编写并且以源代码的形式直接被导入到 Python 中。\ 一些模块提供非常具体的针对 Python 的接口,比如 Python 堆栈跟踪的模块;一些是针对操作系统的,比如\ 操作具体的硬件;还有一些模块提供某一应用领域的接口,比如面向互联网。一些模块可以在任意版本和平台\ 的 Python 中使用;另外一些只能在特定的系统支持的情况下才能使用;还有一些模块只有在编译 Python 时\ 使用了某些特定参数的情况下才能使用。 .. This manual is organized "from the inside out:" it first describes the built-in data types, then the built-in functions and exceptions, and finally the modules, grouped in chapters of related modules. The ordering of the chapters as well as the ordering of the modules within each chapter is roughly from most relevant to least important. 本手册是按照“由内而外”的顺序组织的:首先介绍了内置数据结构,然后是内置函数和异常,最后\ 分别在各个章节介绍相关的各种模块。这些章节的是按照其相关内容的重要程度由重要到不重要的顺序排序的。 .. 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. 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 :mod:`random`) and read a section or two. Regardless of the order in which you read the sections of this manual, it helps to start with chapter :ref:`built-in-funcs`, as the remainder of the manual assumes familiarity with this material. 这就意味着,不管你是从头阅读,还是因为无聊随便翻到某一章节,你都可以获得一个对于当前章节\ 所讲解的模块以及其应用的合理的、全面的了解。当然,你完全不必像阅读一部小说一样阅读这部手册,\ 你可以查阅目录,或者直接在索引中搜索具体的函数、模块、条目。最后,如果你希望学习随机的章节,\ 你可以选择一个随机页码数(模块 :mod:`random` )然后随便阅读一两节。不论你是按照什么顺序阅读\ 手册的各个部分,最好先阅读内置函数( :ref:`built-in-funcs` )这章,因为我们假设当你在阅读\ 手册其他部分的时候你对于内置函数已经很熟悉了。 .. Let the show begin! 那么,现在就开始向大家介绍吧。