@@ -8,7 +8,7 @@ msgstr ""
8
8
"Project-Id-Version : Python 3.13\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
10
"POT-Creation-Date : 2024-09-03 11:11+0800\n "
11
- "PO-Revision-Date : 2023-08-12 15:09 +0800\n "
11
+ "PO-Revision-Date : 2024-12-20 19:16 +0800\n "
12
12
"
Last-Translator :
Li-Hung Wang <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
14
14
"tw)\n "
@@ -128,6 +128,8 @@ msgid ""
128
128
">>> sorted(\" This is a test string from Andrew\" .split(), key=str.casefold)\n"
129
129
"['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']"
130
130
msgstr ""
131
+ ">>> sorted(\" This is a test string from Andrew\" .split(), key=str.casefold)\n"
132
+ "['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']"
131
133
132
134
#: ../../howto/sorting.rst:61
133
135
msgid ""
@@ -157,6 +159,13 @@ msgid ""
157
159
">>> sorted(student_tuples, key=lambda student: student[2]) # sort by age\n"
158
160
"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]"
159
161
msgstr ""
162
+ ">>> student_tuples = [\n"
163
+ "... ('john', 'A', 15),\n"
164
+ "... ('jane', 'B', 12),\n"
165
+ "... ('dave', 'B', 10),\n"
166
+ "... ]\n"
167
+ ">>> sorted(student_tuples, key=lambda student: student[2]) # 依照年齡排序\n"
168
+ "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]"
160
169
161
170
#: ../../howto/sorting.rst:79
162
171
msgid ""
@@ -182,6 +191,22 @@ msgid ""
182
191
"age\n"
183
192
"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]"
184
193
msgstr ""
194
+ ">>> class Student:\n"
195
+ "... def __init__(self, name, grade, age):\n"
196
+ "... self.name = name\n"
197
+ "... self.grade = grade\n"
198
+ "... self.age = age\n"
199
+ "... def __repr__(self):\n"
200
+ "... return repr((self.name, self.grade, self.age))\n"
201
+ "\n"
202
+ ">>> student_objects = [\n"
203
+ "... Student('john', 'A', 15),\n"
204
+ "... Student('jane', 'B', 12),\n"
205
+ "... Student('dave', 'B', 10),\n"
206
+ "... ]\n"
207
+ ">>> sorted(student_objects, key=lambda student: student.age) # 依照年齡排"
208
+ "序\n"
209
+ "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]"
185
210
186
211
#: ../../howto/sorting.rst:99
187
212
msgid ""
@@ -363,6 +388,10 @@ msgid ""
363
388
"primary key, descending\n"
364
389
"[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]"
365
390
msgstr ""
391
+ ">>> s = sorted(student_objects, key=attrgetter('age')) # 依照次要鍵排序\n"
392
+ ">>> sorted(s, key=attrgetter('grade'), reverse=True) # 現在依照主要鍵降"
393
+ "冪排序\n"
394
+ "[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]"
366
395
367
396
#: ../../howto/sorting.rst:193
368
397
msgid ""
@@ -436,6 +465,11 @@ msgid ""
436
465
">>> [student for grade, i, student in decorated] # undecorate\n"
437
466
"[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]"
438
467
msgstr ""
468
+ ">>> decorated = [(student.grade, i, student) for i, student in "
469
+ "enumerate(student_objects)]\n"
470
+ ">>> decorated.sort()\n"
471
+ ">>> [student for grade, i, student in decorated] # 移除裝飾\n"
472
+ "[('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]"
439
473
440
474
#: ../../howto/sorting.rst:231
441
475
msgid ""
@@ -532,7 +566,7 @@ msgstr ""
532
566
533
567
#: ../../howto/sorting.rst:273
534
568
msgid "sorted(words, key=cmp_to_key(strcoll)) # locale-aware sort order"
535
- msgstr ""
569
+ msgstr "sorted(words, key=cmp_to_key(strcoll)) # 理解語系的排序順序 "
536
570
537
571
#: ../../howto/sorting.rst:276
538
572
msgid "Odds and Ends"
@@ -605,10 +639,10 @@ msgid ""
605
639
"six comparison methods be implemented. The :func:`~functools.total_ordering` "
606
640
"decorator is provided to make that task easier."
607
641
msgstr ""
608
- "然而,請注意,當 :meth:`~object.__lt__` 沒有被實做時 ,``<`` 可以回退 (fall "
642
+ "然而,請注意,當 :meth:`~object.__lt__` 沒有被實作時 ,``<`` 可以回退 (fall "
609
643
"back) 使用 :meth:`~object.__gt__`\\ (有關技術上的細節資訊請看 :func:`object."
610
- "__lt__` )。為了避免意外發生,:pep:`8` 建議所有六種的比較函式都需要被實作。裝飾 "
611
- "器 :func:`~functools.total_ordering` 被提供用來讓任務更為簡單。"
644
+ "__lt__` )。為了避免意外發生,:pep:`8` 建議所有六種的比較函式都需要被實作。裝 "
645
+ "飾器 :func:`~functools.total_ordering` 被提供用來讓任務更為簡單。"
612
646
613
647
#: ../../howto/sorting.rst:314
614
648
msgid ""
@@ -672,7 +706,6 @@ msgid ""
672
706
"position ``0``. These functions are suitable for implementing priority "
673
707
"queues which are commonly used for task scheduling."
674
708
msgstr ""
675
- ":func:`heapq.heappush` 和 :func:`heapq.heappop` 會建立並維持一個部份排序的資料"
676
- "排列,將最小的元素保持在位置 ``0``。這些函式適合用來實作常用於任務排程的優先"
677
- "佇列。"
678
-
709
+ ":func:`heapq.heappush` 和 :func:`heapq.heappop` 會建立並維持一個部份排序的資"
710
+ "料排列,將最小的元素保持在位置 ``0``。這些函式適合用來實作常用於任務排程的優"
711
+ "先佇列。"
0 commit comments