-
-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathstdlib2.po
More file actions
369 lines (324 loc) · 18.4 KB
/
stdlib2.po
File metadata and controls
369 lines (324 loc) · 18.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# python-doc bot, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-03 15:28+0000\n"
"PO-Revision-Date: 2025-09-22 16:51+0000\n"
"Last-Translator: python-doc bot, 2025\n"
"Language-Team: Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: zh_CN\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../tutorial/stdlib2.rst:5
msgid "Brief Tour of the Standard Library --- Part II"
msgstr "标准库简介 —— 第二部分"
#: ../../tutorial/stdlib2.rst:7
msgid ""
"This second tour covers more advanced modules that support professional "
"programming needs. These modules rarely occur in small scripts."
msgstr "第二部分涵盖了专业编程所需要的更高级的模块。这些模块很少用在小脚本中。"
#: ../../tutorial/stdlib2.rst:14
msgid "Output Formatting"
msgstr "格式化输出"
#: ../../tutorial/stdlib2.rst:16
msgid ""
"The :mod:`reprlib` module provides a version of :func:`repr` customized for "
"abbreviated displays of large or deeply nested containers::"
msgstr ":mod:`reprlib` 模块提供了一个定制化版本的 :func:`repr` 函数,用于缩略显示大型或深层嵌套的容器对象::"
#: ../../tutorial/stdlib2.rst:23
msgid ""
"The :mod:`pprint` module offers more sophisticated control over printing "
"both built-in and user defined objects in a way that is readable by the "
"interpreter. When the result is longer than one line, the \"pretty printer\""
" adds line breaks and indentation to more clearly reveal data structure::"
msgstr ""
":mod:`pprint` "
"模块提供了更加复杂的打印控制,其输出的内置对象和用户自定义对象能够被解释器直接读取。当输出结果过长而需要折行时,“美化输出机制”会添加换行符和缩进,以更清楚地展示数据结构::"
#: ../../tutorial/stdlib2.rst:39
msgid ""
"The :mod:`textwrap` module formats paragraphs of text to fit a given screen "
"width::"
msgstr ":mod:`textwrap` 模块能够格式化文本段落,以适应给定的屏幕宽度::"
#: ../../tutorial/stdlib2.rst:53
msgid ""
"The :mod:`locale` module accesses a database of culture specific data "
"formats. The grouping attribute of locale's format function provides a "
"direct way of formatting numbers with group separators::"
msgstr ""
":mod:`locale` 模块处理与特定地域文化相关的数据格式。locale 模块的 format 函数包含一个 grouping "
"属性,可直接将数字格式化为带有组分隔符的样式::"
#: ../../tutorial/stdlib2.rst:72
msgid "Templating"
msgstr "模板"
#: ../../tutorial/stdlib2.rst:74
msgid ""
"The :mod:`string` module includes a versatile :class:`~string.Template` "
"class with a simplified syntax suitable for editing by end-users. This "
"allows users to customize their applications without having to alter the "
"application."
msgstr ""
":mod:`string` 模块包含一个通用的 :class:`~string.Template` "
"类,具有适用于最终用户的简化语法。它允许用户在不更改应用逻辑的情况下定制自己的应用。"
#: ../../tutorial/stdlib2.rst:78
msgid ""
"The format uses placeholder names formed by ``$`` with valid Python "
"identifiers (alphanumeric characters and underscores). Surrounding the "
"placeholder with braces allows it to be followed by more alphanumeric "
"letters with no intervening spaces. Writing ``$$`` creates a single escaped"
" ``$``::"
msgstr ""
"上述格式化操作是通过占位符实现的,占位符由 ``$`` 加上合法的 Python "
"标识符(只能包含字母、数字和下划线)构成。一旦使用花括号将占位符括起来,就可以在后面直接跟上更多的字母和数字而无需空格分割。``$$`` "
"将被转义成单个字符 ``$``::"
#: ../../tutorial/stdlib2.rst:88
msgid ""
"The :meth:`~string.Template.substitute` method raises a :exc:`KeyError` when"
" a placeholder is not supplied in a dictionary or a keyword argument. For "
"mail-merge style applications, user supplied data may be incomplete and the "
":meth:`~string.Template.safe_substitute` method may be more appropriate --- "
"it will leave placeholders unchanged if data is missing::"
msgstr ""
"如果在字典或关键字参数中未提供某个占位符的值,那么 :meth:`~string.Template.substitute` 方法将抛出 "
":exc:`KeyError`\\ 。对于邮件合并类型的应用,用户提供的数据有可能是不完整的,此时使用 "
":meth:`~string.Template.safe_substitute` 方法更加合适 —— 如果数据缺失,它会直接将占位符原样保留。"
#: ../../tutorial/stdlib2.rst:103
msgid ""
"Template subclasses can specify a custom delimiter. For example, a batch "
"renaming utility for a photo browser may elect to use percent signs for "
"placeholders such as the current date, image sequence number, or file "
"format::"
msgstr "Template 的子类可以自定义分隔符。例如,以下是某个照片浏览器的批量重命名功能,采用了百分号作为日期、照片序号和照片格式的占位符::"
#: ../../tutorial/stdlib2.rst:126
msgid ""
"Another application for templating is separating program logic from the "
"details of multiple output formats. This makes it possible to substitute "
"custom templates for XML files, plain text reports, and HTML web reports."
msgstr ""
"模板的另一个应用是将程序逻辑与多样的格式化输出细节分离开来。这使得对 XML 文件、纯文本报表和 HTML 网络报表使用自定义模板成为可能。"
#: ../../tutorial/stdlib2.rst:134
msgid "Working with Binary Data Record Layouts"
msgstr "使用二进制数据记录格式"
#: ../../tutorial/stdlib2.rst:136
msgid ""
"The :mod:`struct` module provides :func:`~struct.pack` and "
":func:`~struct.unpack` functions for working with variable length binary "
"record formats. The following example shows how to loop through header "
"information in a ZIP file without using the :mod:`zipfile` module. Pack "
"codes ``\"H\"`` and ``\"I\"`` represent two and four byte unsigned numbers "
"respectively. The ``\"<\"`` indicates that they are standard size and in "
"little-endian byte order::"
msgstr ""
":mod:`struct` 模块提供了 :func:`~struct.pack` 和 :func:`~struct.unpack` "
"函数,用于处理不定长度的二进制记录格式。下面的例子展示了在不使用 :mod:`zipfile` 模块的情况下,如何循环遍历一个 ZIP "
"文件的所有头信息。Pack 代码 ``\"H\"`` 和 ``\"I\"`` 分别代表两字节和四字节无符号整数。\\ ``\"<\"`` "
"代表它们是标准尺寸的小端字节序::"
#: ../../tutorial/stdlib2.rst:167
msgid "Multi-threading"
msgstr "多线程"
#: ../../tutorial/stdlib2.rst:169
msgid ""
"Threading is a technique for decoupling tasks which are not sequentially "
"dependent. Threads can be used to improve the responsiveness of "
"applications that accept user input while other tasks run in the background."
" A related use case is running I/O in parallel with computations in another"
" thread."
msgstr ""
"线程是一种对于非顺序依赖的多个任务进行解耦的技术。多线程可以提高应用的响应效率,当接收用户输入的同时,保持其他任务在后台运行。一个有关的应用场景是,将 "
"I/O 和计算运行在两个并行的线程中。"
#: ../../tutorial/stdlib2.rst:174
msgid ""
"The following code shows how the high level :mod:`threading` module can run "
"tasks in background while the main program continues to run::"
msgstr "以下代码展示了高阶的 :mod:`threading` 模块如何在后台运行任务,且不影响主程序的继续运行::"
#: ../../tutorial/stdlib2.rst:198
msgid ""
"The principal challenge of multi-threaded applications is coordinating "
"threads that share data or other resources. To that end, the threading "
"module provides a number of synchronization primitives including locks, "
"events, condition variables, and semaphores."
msgstr ""
"多线程应用面临的主要挑战是,相互协调的多个线程之间需要共享数据或其他资源。为此,threading "
"模块提供了多个同步操作原语,包括线程锁、事件、条件变量和信号量。"
#: ../../tutorial/stdlib2.rst:203
msgid ""
"While those tools are powerful, minor design errors can result in problems "
"that are difficult to reproduce. So, the preferred approach to task "
"coordination is to concentrate all access to a resource in a single thread "
"and then use the :mod:`queue` module to feed that thread with requests from "
"other threads. Applications using :class:`~queue.Queue` objects for inter-"
"thread communication and coordination are easier to design, more readable, "
"and more reliable."
msgstr ""
"尽管这些工具非常强大,但微小的设计错误却可以导致一些难以复现的问题。因此,实现多任务协作的首选方法是将所有对资源的请求集中到一个线程中,然后使用 "
":mod:`queue` 模块向该线程供应来自其他线程的请求。 应用程序使用 :class:`~queue.Queue` "
"对象进行线程间通信和协调,更易于设计,更易读,更可靠。"
#: ../../tutorial/stdlib2.rst:214
msgid "Logging"
msgstr "日志记录"
#: ../../tutorial/stdlib2.rst:216
msgid ""
"The :mod:`logging` module offers a full featured and flexible logging "
"system. At its simplest, log messages are sent to a file or to "
"``sys.stderr``::"
msgstr ""
":mod:`logging` 模块提供功能齐全且灵活的日志记录系统。在最简单的情况下,日志消息被发送到文件或 ``sys.stderr``\\ ::"
#: ../../tutorial/stdlib2.rst:226
msgid "This produces the following output:"
msgstr "这会产生以下输出:"
#: ../../tutorial/stdlib2.rst:234
msgid ""
"By default, informational and debugging messages are suppressed and the "
"output is sent to standard error. Other output options include routing "
"messages through email, datagrams, sockets, or to an HTTP Server. New "
"filters can select different routing based on message priority: "
":const:`~logging.DEBUG`, :const:`~logging.INFO`, :const:`~logging.WARNING`, "
":const:`~logging.ERROR`, and :const:`~logging.CRITICAL`."
msgstr ""
"默认情况下,informational 和 debugging "
"消息被压制,输出会发送到标准错误流。其他输出选项包括将消息转发到电子邮件,数据报,套接字或 HTTP "
"服务器。新的过滤器可以根据消息优先级选择不同的路由方式:\\ :const:`~logging.DEBUG`\\ ,\\ "
":const:`~logging.INFO`\\ ,\\ :const:`~logging.WARNING`\\ ,\\ "
":const:`~logging.ERROR`\\ ,和 :const:`~logging.CRITICAL`\\ 。"
#: ../../tutorial/stdlib2.rst:241
msgid ""
"The logging system can be configured directly from Python or can be loaded "
"from a user editable configuration file for customized logging without "
"altering the application."
msgstr "日志系统可以直接从 Python 配置,也可以从用户配置文件加载,以便自定义日志记录而无需更改应用程序。"
#: ../../tutorial/stdlib2.rst:249
msgid "Weak References"
msgstr "弱引用"
#: ../../tutorial/stdlib2.rst:251
msgid ""
"Python does automatic memory management (reference counting for most objects"
" and :term:`garbage collection` to eliminate cycles). The memory is freed "
"shortly after the last reference to it has been eliminated."
msgstr ""
"Python 会自动进行内存管理(对大多数对象进行引用计数并使用 :term:`garbage collection` 来清除循环引用)。 "
"当某个对象的最后一个引用被移除后不久就会释放其所占用的内存。"
#: ../../tutorial/stdlib2.rst:255
msgid ""
"This approach works fine for most applications but occasionally there is a "
"need to track objects only as long as they are being used by something else."
" Unfortunately, just tracking them creates a reference that makes them "
"permanent. The :mod:`weakref` module provides tools for tracking objects "
"without creating a reference. When the object is no longer needed, it is "
"automatically removed from a weakref table and a callback is triggered for "
"weakref objects. Typical applications include caching objects that are "
"expensive to create::"
msgstr ""
"此方式对大多数应用来说都适用,但偶尔也必须在对象持续被其他对象所使用时跟踪它们。 不幸的是,跟踪它们将创建一个会令其永久化的引用。 "
":mod:`weakref` 模块提供的工具可以不必创建引用就能跟踪对象。 "
"当对象不再需要时,它将自动从一个弱引用表中被移除,并为弱引用对象触发一个回调。 典型应用包括对创建开销较大的对象进行缓存::"
#: ../../tutorial/stdlib2.rst:290
msgid "Tools for Working with Lists"
msgstr "用于操作列表的工具"
#: ../../tutorial/stdlib2.rst:292
msgid ""
"Many data structure needs can be met with the built-in list type. However, "
"sometimes there is a need for alternative implementations with different "
"performance trade-offs."
msgstr "许多对于数据结构的需求可以通过内置列表类型来满足。 但是,有时也会需要具有不同效费比的替代实现。"
#: ../../tutorial/stdlib2.rst:296
msgid ""
"The :mod:`array` module provides an :class:`~array.array()` object that is "
"like a list that stores only homogeneous data and stores it more compactly."
" The following example shows an array of numbers stored as two byte "
"unsigned binary numbers (typecode ``\"H\"``) rather than the usual 16 bytes "
"per entry for regular lists of Python int objects::"
msgstr ""
":mod:`array` 模块提供了一种 :class:`~array.array()` "
"对象,它类似于列表,但只能存储类型一致的数据且存储密度更高。下面演示了一个用双字节无符号整数数组来储存整数的例子(类型码为 "
"``\"H\"``),而通常的用 Python 的 int 对象来储存整数的列表,每个表项通常要使用 16 个字节:"
#: ../../tutorial/stdlib2.rst:309
msgid ""
"The :mod:`collections` module provides a :class:`~collections.deque()` "
"object that is like a list with faster appends and pops from the left side "
"but slower lookups in the middle. These objects are well suited for "
"implementing queues and breadth first tree searches::"
msgstr ""
":mod:`collections` 模块提供了一种 :class:`~collections.deque()` "
"对象,它类似于列表,但从左端添加和弹出的速度较快,而在中间查找的速度较慢。 此种对象适用于实现队列和广度优先树搜索::"
#: ../../tutorial/stdlib2.rst:330
msgid ""
"In addition to alternative list implementations, the library also offers "
"other tools such as the :mod:`bisect` module with functions for manipulating"
" sorted lists::"
msgstr "在替代的列表实现以外,标准库也提供了其他工具,例如 :mod:`bisect` 模块具有用于操作有序列表的函数::"
#: ../../tutorial/stdlib2.rst:340
msgid ""
"The :mod:`heapq` module provides functions for implementing heaps based on "
"regular lists. The lowest valued entry is always kept at position zero. "
"This is useful for applications which repeatedly access the smallest element"
" but do not want to run a full list sort::"
msgstr ""
":mod:`heapq` 模块提供了基于常规列表来实现堆的函数。 最小值的条目总是保持在位置零。 "
"这对于需要重复访问最小元素而不希望运行完整列表排序的应用来说非常有用::"
#: ../../tutorial/stdlib2.rst:356
msgid "Decimal Floating Point Arithmetic"
msgstr "十进制浮点运算"
#: ../../tutorial/stdlib2.rst:358
msgid ""
"The :mod:`decimal` module offers a :class:`~decimal.Decimal` datatype for "
"decimal floating point arithmetic. Compared to the built-in :class:`float` "
"implementation of binary floating point, the class is especially helpful for"
msgstr ""
":mod:`decimal` 模块提供了一种 :class:`~decimal.Decimal` 数据类型用于十进制浮点运算。 相比内置的 "
":class:`float` 二进制浮点实现,该类特别适用于"
#: ../../tutorial/stdlib2.rst:362
msgid ""
"financial applications and other uses which require exact decimal "
"representation,"
msgstr "财务应用和其他需要精确十进制表示的用途,"
#: ../../tutorial/stdlib2.rst:364
msgid "control over precision,"
msgstr "控制精度,"
#: ../../tutorial/stdlib2.rst:365
msgid "control over rounding to meet legal or regulatory requirements,"
msgstr "控制四舍五入以满足法律或监管要求,"
#: ../../tutorial/stdlib2.rst:366
msgid "tracking of significant decimal places, or"
msgstr "跟踪有效小数位,或"
#: ../../tutorial/stdlib2.rst:367
msgid ""
"applications where the user expects the results to match calculations done "
"by hand."
msgstr "用户期望结果与手工完成的计算相匹配的应用程序。"
#: ../../tutorial/stdlib2.rst:370
msgid ""
"For example, calculating a 5% tax on a 70 cent phone charge gives different "
"results in decimal floating point and binary floating point. The difference "
"becomes significant if the results are rounded to the nearest cent::"
msgstr "例如,使用十进制浮点和二进制浮点数计算70美分手机和5%税的总费用,会产生的不同结果。如果结果四舍五入到最接近的分数差异会更大::"
#: ../../tutorial/stdlib2.rst:380
msgid ""
"The :class:`~decimal.Decimal` result keeps a trailing zero, automatically "
"inferring four place significance from multiplicands with two place "
"significance. Decimal reproduces mathematics as done by hand and avoids "
"issues that can arise when binary floating point cannot exactly represent "
"decimal quantities."
msgstr ""
":class:`~decimal.Decimal` 表示的结果会保留尾部的零,并根据具有两个有效位的被乘数自动推出四个有效位。 Decimal "
"可以模拟手工运算来避免当二进制浮点数无法精确表示十进制数时会导致的问题。"
#: ../../tutorial/stdlib2.rst:386
msgid ""
"Exact representation enables the :class:`~decimal.Decimal` class to perform "
"modulo calculations and equality tests that are unsuitable for binary "
"floating point::"
msgstr "精确表示特性使得 :class:`~decimal.Decimal` 类能够执行对于二进制浮点数来说不适用的模运算和相等性检测::"
#: ../../tutorial/stdlib2.rst:400
msgid ""
"The :mod:`decimal` module provides arithmetic with as much precision as "
"needed::"
msgstr ":mod:`decimal` 模块提供了运算所需要的足够精度::"