@@ -9,7 +9,7 @@ msgstr ""
9
9
"Project-Id-Version : Python 3.12\n "
10
10
"Report-Msgid-Bugs-To : \n "
11
11
"POT-Creation-Date : 2023-07-24 00:03+0000\n "
12
- "PO-Revision-Date : 2023-08-09 18:16 +0800\n "
12
+ "PO-Revision-Date : 2023-08-12 15:09 +0800\n "
13
13
"
Last-Translator :
Adrian Liaw <[email protected] >\n "
14
14
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
15
15
"tw)\n "
@@ -216,51 +216,57 @@ msgstr ""
216
216
217
217
#: ../../howto/sorting.rst:190
218
218
msgid "Decorate-Sort-Undecorate"
219
- msgstr ""
219
+ msgstr "裝飾-排序-移除裝飾 (decorate-sort-undecorate) "
220
220
221
221
#: ../../howto/sorting.rst:192
222
222
msgid "This idiom is called Decorate-Sort-Undecorate after its three steps:"
223
- msgstr ""
223
+ msgstr "這個用語的來源是因為它做了以下三件事情: "
224
224
225
225
#: ../../howto/sorting.rst:194
226
226
msgid ""
227
227
"First, the initial list is decorated with new values that control the sort "
228
228
"order."
229
- msgstr ""
229
+ msgstr "首先,原始串列會裝飾 (decorated) 上新的值用來控制排序的順序。 "
230
230
231
231
#: ../../howto/sorting.rst:196
232
232
msgid "Second, the decorated list is sorted."
233
- msgstr ""
233
+ msgstr "接下來,排序裝飾過的串列。 "
234
234
235
235
#: ../../howto/sorting.rst:198
236
236
msgid ""
237
237
"Finally, the decorations are removed, creating a list that contains only the "
238
238
"initial values in the new order."
239
- msgstr ""
239
+ msgstr "最後,裝飾會被移除,並以新的順序產生一個只包含原始值的串列。 "
240
240
241
241
#: ../../howto/sorting.rst:201
242
242
msgid ""
243
243
"For example, to sort the student data by *grade* using the DSU approach:"
244
- msgstr ""
244
+ msgstr "例如用上面說的方式來以 *grade* 排序學生資料: "
245
245
246
246
#: ../../howto/sorting.rst:208
247
247
msgid ""
248
248
"This idiom works because tuples are compared lexicographically; the first "
249
249
"items are compared; if they are the same then the second items are compared, "
250
250
"and so on."
251
251
msgstr ""
252
+ "這個方式會有效是因為元組是依照字典順序 (lexicographically) 來比較,先比較第"
253
+ "一個項目,如果一樣再比較第二個項目,並依此類推。"
252
254
253
255
#: ../../howto/sorting.rst:212
254
256
msgid ""
255
257
"It is not strictly necessary in all cases to include the index *i* in the "
256
258
"decorated list, but including it gives two benefits:"
257
259
msgstr ""
260
+ "在所有情況下都把索引 *i* 加入已裝飾的串列並不是絕對需要的,但這樣做會有兩個好"
261
+ "處:"
258
262
259
263
#: ../../howto/sorting.rst:215
260
264
msgid ""
261
265
"The sort is stable -- if two items have the same key, their order will be "
262
266
"preserved in the sorted list."
263
267
msgstr ""
268
+ "排序會是穩定的 -- 如果兩個項目有相同的鍵,它們在排序好的串列中會保持原來的順"
269
+ "序。"
264
270
265
271
#: ../../howto/sorting.rst:218
266
272
msgid ""
@@ -269,29 +275,34 @@ msgid ""
269
275
"example the original list could contain complex numbers which cannot be "
270
276
"sorted directly."
271
277
msgstr ""
278
+ "原始項目不需要是可以比較的,因為最多只會用到前兩個項目就能決定裝飾過的元組的"
279
+ "順序。例如原始串列可以包含不能直接用來排序的複數。"
272
280
273
281
#: ../../howto/sorting.rst:223
274
282
msgid ""
275
283
"Another name for this idiom is `Schwartzian transform <https://en.wikipedia."
276
284
"org/wiki/Schwartzian_transform>`_\\ , after Randal L. Schwartz, who "
277
285
"popularized it among Perl programmers."
278
286
msgstr ""
287
+ "這個用語的另一個名字是 `Schwartzian transform <https://en.wikipedia.org/wiki/"
288
+ "Schwartzian_transform>`_\\ ,是由於 Randal L. Schwartz 讓這個方法在 Perl 程式"
289
+ "設計師間普及。"
279
290
280
291
#: ../../howto/sorting.rst:227
281
292
msgid ""
282
293
"Now that Python sorting provides key-functions, this technique is not often "
283
294
"needed."
284
- msgstr ""
295
+ msgstr "而因為 Python 的排序提供了鍵函式,已經不太需要用到這個方法了。 "
285
296
286
297
#: ../../howto/sorting.rst:230
287
298
msgid "Comparison Functions"
288
- msgstr ""
299
+ msgstr "比較函式 (comparison functions) "
289
300
290
301
#: ../../howto/sorting.rst:232
291
302
msgid ""
292
303
"Unlike key functions that return an absolute value for sorting, a comparison "
293
304
"function computes the relative ordering for two inputs."
294
- msgstr ""
305
+ msgstr "不像鍵函式回傳一個用來排序的值,比較函式計算兩個輸入間的相對順序。 "
295
306
296
307
#: ../../howto/sorting.rst:235
297
308
msgid ""
@@ -301,6 +312,10 @@ msgid ""
301
312
"function such as ``cmp(a, b)`` will return a negative value for less-than, "
302
313
"zero if the inputs are equal, or a positive value for greater-than."
303
314
msgstr ""
315
+ "例如\\ `天秤 <https://upload.wikimedia.org/wikipedia/commons/1/17/"
316
+ "Balance_à_tabac_1850.JPG>`_\\ 比較兩邊樣本並給出相對的順序:較輕、相同或較"
317
+ "重。同樣地,像是 ``cmp(a, b)`` 這樣的比較函式會回傳負數代表小於、0 代表輸入相"
318
+ "同或正數代表大於。"
304
319
305
320
#: ../../howto/sorting.rst:242
306
321
msgid ""
@@ -309,17 +324,21 @@ msgid ""
309
324
"part of their API. For example, :func:`locale.strcoll` is a comparison "
310
325
"function."
311
326
msgstr ""
327
+ "當從其它語言翻譯演算法的時候常看到比較函式。有些函式庫也會提供比較函式作為其 "
328
+ "API 的一部份,例如 :func:`locale.strcoll` 就是一個比較函式。"
312
329
313
330
#: ../../howto/sorting.rst:246
314
331
msgid ""
315
332
"To accommodate those situations, Python provides :class:`functools."
316
333
"cmp_to_key` to wrap the comparison function to make it usable as a key "
317
334
"function::"
318
335
msgstr ""
336
+ "為了滿足這些情境,Python 提供 :class:`functools.cmp_to_key` 來包裝比較函式,"
337
+ "讓其可以當作鍵函式來使用: ::"
319
338
320
339
#: ../../howto/sorting.rst:253
321
340
msgid "Odds and Ends"
322
- msgstr ""
341
+ msgstr "雜項說明 "
323
342
324
343
#: ../../howto/sorting.rst:255
325
344
msgid ""
@@ -328,6 +347,9 @@ msgid ""
328
347
"\" alphabetical\" sort orderings can vary across cultures even if the "
329
348
"underlying alphabet is the same."
330
349
msgstr ""
350
+ "要處理能理解本地語系 (locale aware) 的排序可以使用 :func:`locale.strxfrm` 當"
351
+ "作鍵函式,或 :func:`locale.strcoll` 當作比較函式。這樣做是必要的,因為在不同"
352
+ "文化中就算是相同的字母,按「字母順序」排序的結果也各不相同。"
331
353
332
354
#: ../../howto/sorting.rst:260
333
355
msgid ""
@@ -336,19 +358,26 @@ msgid ""
336
358
"simulated without the parameter by using the builtin :func:`reversed` "
337
359
"function twice:"
338
360
msgstr ""
361
+ "*reverse* 參數依然會維持排序穩定性(即有相同鍵的資料會保持原來順序)。有趣的"
362
+ "是,不加這個參數也可以模擬這個效果,只要使用內建的 :func:`reversed` 函式兩"
363
+ "次:"
339
364
340
365
#: ../../howto/sorting.rst:274
341
366
msgid ""
342
367
"The sort routines use ``<`` when making comparisons between two objects. So, "
343
368
"it is easy to add a standard sort order to a class by defining an :meth:"
344
369
"`~object.__lt__` method:"
345
370
msgstr ""
371
+ "排序時會使用 ``<`` 來比較兩個物件,因此要在類別裡面加入排序順序比較規則是簡單"
372
+ "的,只要透過定義 :meth:`~object.__lt__` 方法:"
346
373
347
374
#: ../../howto/sorting.rst:284
348
375
msgid ""
349
376
"However, note that ``<`` can fall back to using :meth:`~object.__gt__` if :"
350
377
"meth:`~object.__lt__` is not implemented (see :func:`object.__lt__`)."
351
378
msgstr ""
379
+ "然而,需要注意如果沒有實作 :meth:`~object.__lt__`,則 ``<`` 會退而使用 :meth:"
380
+ "`~object.__gt__`\\ (參見 :func:`object.__lt__`)。"
352
381
353
382
#: ../../howto/sorting.rst:287
354
383
msgid ""
@@ -357,3 +386,5 @@ msgid ""
357
386
"grades are stored in a dictionary, they can be used to sort a separate list "
358
387
"of student names:"
359
388
msgstr ""
389
+ "鍵函式不需要直接依賴用來排序的物件。鍵函式也可以存取外部資源,例如如果學生成"
390
+ "績儲存在字典裡,它可以用來排序一個單獨的學生姓名串列:"
0 commit comments