@@ -41,9 +41,9 @@ msgid ""
4141" You may also want to use a handy function that you've written in several "
4242"programs without copying its definition into each program."
4343msgstr ""
44- "退出 Python "
45- "解释器,再次进入时,会丢失以前(函数和变量)的定义。因此,在编写较长程序时,最好用文本编辑器代替解释器,执行文件中的输入内容,这就是编写 *脚本* "
46- "。随着程序越来越长,为了便于维护 ,最好把一个脚本拆分成多个文件。还一种情况,是在不同程序中使用同一个函数时,不要每次都把函数复制到各个程序 。"
44+ "退出 Python 解释器再次进入时,以前定义的函数和变量就丢失了。因此,在编写较长程序时,最好用文本编辑器代替解释器,执行文件中的输入内容,这就是编写 "
45+ " *脚本* "
46+ "。随着程序越来越长,为了方便维护 ,最好把一个脚本拆分成多个文件。还一种情况,是在不同程序中使用同一个函数时,不用每次都要把函数复制到各个程序 。"
4747
4848#: ../../tutorial/modules.rst:16
4949msgid ""
@@ -54,7 +54,7 @@ msgid ""
5454" access to in a script executed at the top level and in calculator mode)."
5555msgstr ""
5656"为实现这些需求,Python 可以把各种定义存入一个文件,在脚本或解释器的交互式实例中使用。这个文件就是 *模块* ;模块中的定义可以 *导入* "
57- "到其他模块或 *主* 模块(在顶层和计算器模式下,执行的脚本中可访问的变量集 )。"
57+ "到其他模块或 *主* 模块(在顶层和计算器模式下,执行脚本中可访问的变量集 )。"
5858
5959#: ../../tutorial/modules.rst:22
6060msgid ""
@@ -65,8 +65,8 @@ msgid ""
6565"to create a file called :file:`fibo.py` in the current directory with the "
6666"following contents::"
6767msgstr ""
68- "模块是包含 Python 定义和语句的文件。文件名就是模块名加后缀名 :file:`.py` 。在模块内部,模块名(即字符串) 通过全局变量 "
69- "``__name__`` 的值获取 。例如,用文本编辑器在当前目录下创建名为 :file:`fibo.py` 的文件,并写入以下内容 :"
68+ "模块是包含 Python 定义和语句的文件。文件名就是模块名加后缀名 :file:`.py` 。在模块内部,通过全局变量 ``__name__`` "
69+ "可以获取模块名(即字符串) 。例如,用文本编辑器在当前目录下创建 :file:`fibo.py` 文件,输入以下内容 :"
7070
7171#: ../../tutorial/modules.rst:45
7272msgid ""
@@ -79,7 +79,7 @@ msgid ""
7979"This does not enter the names of the functions defined in ``fibo`` directly"
8080" in the current symbol table; it only enters the module name ``fibo`` there."
8181" Using the module name you can access the functions::"
82- msgstr "这项操作不把 ``fibo`` 函数定义的名称直接输入到当前符号表,只输入模块名 ``fibo`` 。使用模块名可以访问这些函数 :"
82+ msgstr "这项操作不会把 ``fibo`` 函数定义的名称直接导入到当前符号表,只导入模块名 ``fibo`` 。需要使用模块名访问函数 :"
8383
8484#: ../../tutorial/modules.rst:61
8585msgid ""
@@ -109,7 +109,7 @@ msgid ""
109109" know what you are doing you can touch a module's global variables with the "
110110"same notation used to refer to its functions, ``modname.itemname``."
111111msgstr ""
112- "每个模块都有自己的私有符号表,用作模块中定义的所有函数的全局符号表 。因此,可以在模块内使用全局变量,不用担心与用户的全局变量发生意外冲突 。另一方面,可以用与访问模块内函数同样的标记法 ,访问模块的全局变量,``modname.itemname``。"
112+ "每个模块都有自己的私有符号表,也就是模块中所有函数的全局符号表 。因此,在模块内使用全局变量时,不用担心与用户定义的全局变量发生冲突 。另一方面,可以用访问模块内函数一样的标记法 ,访问模块的全局变量,``modname.itemname``。"
113113
114114#: ../../tutorial/modules.rst:85
115115msgid ""
@@ -126,17 +126,17 @@ msgid ""
126126"There is a variant of the :keyword:`import` statement that imports names "
127127"from a module directly into the importing module's symbol table. For "
128128"example::"
129- msgstr ":keyword:`import` 语句有一个变体,可以直接把模块里的名称导入到另一个模块的符号表里 。例如:"
129+ msgstr ":keyword:`import` 语句有一个变体,可以直接把模块里的名称导入到另一个模块的符号表 。例如:"
130130
131131#: ../../tutorial/modules.rst:97
132132msgid ""
133133"This does not introduce the module name from which the imports are taken in "
134134"the local symbol table (so in the example, ``fibo`` is not defined)."
135- msgstr "这段代码不会把模块名导入到局部符号表里(因此,本例未能定义 ``fibo``)。"
135+ msgstr "这段代码不会把模块名导入到局部符号表里(因此,本例没有定义 ``fibo``)。"
136136
137137#: ../../tutorial/modules.rst:100
138138msgid "There is even a variant to import all names that a module defines::"
139- msgstr "还有一个变体甚至可以导入模块内定义的所有名称 :"
139+ msgstr "还有一种变体还可以导入模块内定义的所有名称 :"
140140
141141#: ../../tutorial/modules.rst:106
142142msgid ""
@@ -145,33 +145,32 @@ msgid ""
145145"an unknown set of names into the interpreter, possibly hiding some things "
146146"you have already defined."
147147msgstr ""
148- "调入所有不以下划线(``_``)开头的名称。大多数情况下,Python "
149- "程序员都不愿意使用这个功能,因为,它在解释器中引入了一堆未知名称,可能会覆盖已经定义的名称。"
148+ "这种方式会导入所有不以下划线(``_``)开头的名称。大多数情况下,不要用这个功能,这种方式向解释器引入了一堆未知名称,可能会覆盖已经定义的名称。"
150149
151150#: ../../tutorial/modules.rst:111
152151msgid ""
153152"Note that in general the practice of importing ``*`` from a module or "
154153"package is frowned upon, since it often causes poorly readable code. "
155154"However, it is okay to use it to save typing in interactive sessions."
156155msgstr ""
157- "注意,一般情况下,不建议从模块或包内导入 ``*``, 因为,这项操作常让代码的可读性变差 。不过,为了在交互式编译器中少打几个字,这么用也没问题。 "
156+ "注意,一般情况下,不建议从模块或包内导入 ``*``, 因为,这项操作常让代码变得难以理解 。不过,为了在交互式编译器中少打几个字,这么用也没问题。 "
158157
159158#: ../../tutorial/modules.rst:115
160159msgid ""
161160"If the module name is followed by :keyword:`!as`, then the name following "
162161":keyword:`!as` is bound directly to the imported module."
163- msgstr "模块名后使用 :keyword:`!as` 时,:keyword:`!as` 之后的名称直接绑定到导入的模块 。"
162+ msgstr "模块名后使用 :keyword:`!as` 时,:keyword:`!as` 之后的名称直接与导入模块绑定 。"
164163
165164#: ../../tutorial/modules.rst:124
166165msgid ""
167166"This is effectively importing the module in the same way that ``import "
168167"fibo`` will do, with the only difference of it being available as ``fib``."
169- msgstr "与 ``import fibo`` 一样,这样也可以有效地导入模块, 唯一的区别是,导入的名称是 ``fib``。"
168+ msgstr "与 ``import fibo`` 一样,这种方式也可以有效地导入模块, 唯一的区别是,导入的名称是 ``fib``。"
170169
171170#: ../../tutorial/modules.rst:127
172171msgid ""
173172"It can also be used when utilising :keyword:`from` with similar effects::"
174- msgstr "这种方式也可以在 :keyword:`from` 中使用 ,效果类似:"
173+ msgstr ":keyword:`from` 中也可以使用这种方式 ,效果类似:"
175174
176175#: ../../tutorial/modules.rst:136
177176msgid ""
@@ -181,7 +180,7 @@ msgid ""
181180"use :func:`importlib.reload`, e.g. ``import importlib; "
182181"importlib.reload(modulename)``."
183182msgstr ""
184- "为了保证效率,每个模块在每次解释器会话中只导入一次。因此, 如果更改了模块,则必须重新启动解释器,-- 或, 仅交互测试一个模块时,使用 "
183+ "为了保证效率,模块在每次解释器会话中只导入一次。 如果更改了模块,必须要重启解释器; 仅交互测试一个模块时,也可以使用 "
185184":func:`importlib.reload`,例如 ``import importlib; "
186185"importlib.reload(modulename)``。"
187186
@@ -191,22 +190,22 @@ msgstr "以脚本的方式执行模块"
191190
192191#: ../../tutorial/modules.rst:148
193192msgid "When you run a Python module with ::"
194- msgstr "用以下方式运行 Python 模块时 :"
193+ msgstr "可以用以下方式运行 Python 模块 :"
195194
196195#: ../../tutorial/modules.rst:152
197196msgid ""
198197"the code in the module will be executed, just as if you imported it, but "
199198"with the ``__name__`` set to ``\" __main__\" ``. That means that by adding "
200199"this code at the end of your module::"
201200msgstr ""
202- "这项操作将执行模块里的代码,和导入模块一样,但会把 ``__name__`` 赋值给 ``\" __main__\" ``。即,把这些代码添加到模块末尾 :"
201+ "这项操作将执行模块里的代码,和导入模块一样,但会把 ``__name__`` 赋值给 ``\" __main__\" ``。即,把下列代码添加到模块末尾 :"
203202
204203#: ../../tutorial/modules.rst:160
205204msgid ""
206205"you can make the file usable as a script as well as an importable module, "
207206"because the code that parses the command line only runs if the module is "
208207"executed as the \" main\" file:"
209- msgstr "既可以把这个文件用作脚本 ,也可以用作导入的模块, 因为,解析命令行的代码只有在模块以 “main” 文件执行的时候才会运行 :"
208+ msgstr "既可以把这个文件当脚本使用 ,也可以用作导入的模块, 因为,解析命令行的代码只有在模块以 “main” 文件执行时才会运行 :"
210209
211210#: ../../tutorial/modules.rst:169
212211msgid "If the module is imported, the code is not run::"
@@ -230,8 +229,8 @@ msgid ""
230229"file named :file:`spam.py` in a list of directories given by the variable "
231230":data:`sys.path`. :data:`sys.path` is initialized from these locations:"
232231msgstr ""
233- "导入名为 :mod:`spam` 的模块时,解释器首先查找名为 `spam` 的内置模块。如果没找到,解释器再从 :data:`sys.path` "
234- "变量中的目录列表里寻找名为 :file:`spam.py` 的文件 。:data:`sys.path` 初始化时包含以下位置:"
232+ "导入 :mod:`spam` 的模块时,解释器首先查找名为 `spam` 的内置模块。如果没找到,解释器再从 :data:`sys.path` "
233+ "变量中的目录列表里寻找 :file:`spam.py` 文件 。:data:`sys.path` 初始化时包含以下位置:"
235234
236235#: ../../tutorial/modules.rst:190
237236msgid ""
@@ -243,19 +242,19 @@ msgstr "输入脚本的目录(或未指定文件时的当前目录)。"
243242msgid ""
244243":envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the"
245244" shell variable :envvar:`PATH`)."
246- msgstr ":envvar:`PYTHONPATH` (包含目录名称的列表 ,与 shell 变量 :envvar:`PATH` 的语法一样)。"
245+ msgstr ":envvar:`PYTHONPATH` (目录列表 ,与 shell 变量 :envvar:`PATH` 的语法一样)。"
247246
248247#: ../../tutorial/modules.rst:194
249248msgid "The installation-dependent default."
250- msgstr "默认的安装目录 。"
249+ msgstr "默认安装目录 。"
251250
252251#: ../../tutorial/modules.rst:197
253252msgid ""
254253"On file systems which support symlinks, the directory containing the input "
255254"script is calculated after the symlink is followed. In other words the "
256255"directory containing the symlink is **not** added to the module search path."
257256msgstr ""
258- "在支持 symlink 的文件系统中,包含输入脚本的目录是在追加 symlink 后计算出来的。换句话说,包含 symlink 的目录并 **没有** "
257+ "在支持 symlink 的文件系统中,输入脚本目录是在追加 symlink 后计算出来的。换句话说,包含 symlink 的目录并 **没有** "
259258"添加到模块搜索路径上。 "
260259
261260#: ../../tutorial/modules.rst:201
@@ -267,9 +266,9 @@ msgid ""
267266"library directory. This is an error unless the replacement is intended. See"
268267" section :ref:`tut-standardmodules` for more information."
269268msgstr ""
270- "初始化后,Python 程序可以更改 :data:`sys.path`。包含运行脚本的目录置于搜索路径的开头, "
271- "在标准库路径之前。 即,加载的是该目录里的脚本,而不是标准库中的同名模块。 除非刻意替换,否则会报错。详见 :ref:`tut- "
272- "standardmodules`。"
269+ "初始化后,Python 程序可以更改 "
270+ ":data:`sys.path`。运行脚本的目录在标准库路径之前,置于搜索路径的开头。 即,加载的是该目录里的脚本,而不是标准库的同名模块。 "
271+ "除非刻意替换,否则会报错。详见 :ref:`tut- standardmodules`。"
273272
274273#: ../../tutorial/modules.rst:212
275274msgid "\" Compiled\" Python files"
@@ -286,9 +285,9 @@ msgid ""
286285"allows compiled modules from different releases and different versions of "
287286"Python to coexist."
288287msgstr ""
289- "为了加速载入模块 ,Python 把每个模块的编译版缓存在 ``__pycache__`` 目录中,文件名为 "
288+ "为了快速加载模块 ,Python 把模块的编译版缓存在 ``__pycache__`` 目录中,文件名为 "
290289":file:`module.{version}.pyc`,version 对编译文件格式进行编码,一般是 Python 的版本号。例如,CPython "
291- "的 3.3 发行版中,spam.py 的编译版本缓存为 ``__pycache__/spam.cpython-33.pyc``。此命名约定支持 "
290+ "的 3.3 发行版中,spam.py 的编译版本缓存为 ``__pycache__/spam.cpython-33.pyc``。此命名惯例支持 "
292291"Python 的不同发行版和不同版本的已编译模块共存。"
293292
294293#: ../../tutorial/modules.rst:222
0 commit comments