diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index 5b3bfd966c..b34c9beecb 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -1,5 +1,5 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) 2001-2018, Python Software Foundation +# Copyright (C) 2001-2021, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: @@ -9,13 +9,14 @@ # Liang-Bo Wang , 2015-2016 # Liang-Bo Wang , 2016 # hsiao yi , 2015 +# Steven Hsu , 2021 msgid "" msgstr "" -"Project-Id-Version: Python 3.7\n" +"Project-Id-Version: Python 3.9\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-20 18:08+0800\n" -"PO-Revision-Date: 2018-10-14 09:57+0800\n" -"Last-Translator: Ching-Hao Liu \n" +"POT-Creation-Date: 2021-05-21 15:41+0800\n" +"PO-Revision-Date: 2021-05-24 11:34+0800\n" +"Last-Translator: Steven Hsu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -23,7 +24,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Poedit 2.1.1\n" +"X-Generator: Poedit 2.4.3\n" #: ../../tutorial/datastructures.rst:5 msgid "Data Structures" @@ -46,8 +47,8 @@ msgid "" "The list data type has some more methods. Here are all of the methods of " "list objects:" msgstr "" -"List(串列)這個資料型態,具有更多操作的方法。下面條列了所有關於 list 的物件" -"方法:" +"List(串列)這個資料型態,具有更多操作的方法。下面條列了所有關於 list 物件的 " +"method:" #: ../../tutorial/datastructures.rst:22 msgid "" @@ -59,7 +60,7 @@ msgid "" "Extend the list by appending all the items from the iterable. Equivalent to " "``a[len(a):] = iterable``." msgstr "" -"將 iterable(可列舉物件)接到 list 的尾端。等同於 ``a[len(a):] = iterable``。" +"將 iterable(可疊代物件)接到 list 的尾端。等同於 ``a[len(a):] = iterable``。" #: ../../tutorial/datastructures.rst:35 msgid "" @@ -68,17 +69,16 @@ msgid "" "of the list, and ``a.insert(len(a), x)`` is equivalent to ``a.append(x)``." msgstr "" "將一個項目插入至 list 中給定的位置。第一個引數為插入處前元素的索引值,所以 " -"``a.insert(0, x)`` 會插入為 list 首位,而 ``a.insert(len(a), x)`` 則相當於 " +"``a.insert(0, x)`` 會插入在 list 首位,而 ``a.insert(len(a), x)`` 則相當於 " "``a.append(x)``。" #: ../../tutorial/datastructures.rst:43 -#, fuzzy msgid "" "Remove the first item from the list whose value is equal to *x*. It raises " "a :exc:`ValueError` if there is no such item." msgstr "" -"刪除 list 中第一個值等於 *x* 的元素。若 list 中無此元素則會觸發 " -"``ValueError``。" +"刪除 list 中第一個值等於 *x* 的元素。若 list 中無此元素則會觸發 :exc:" +"`ValueError`\\ 。" #: ../../tutorial/datastructures.rst:50 msgid "" @@ -96,7 +96,7 @@ msgstr "" #: ../../tutorial/datastructures.rst:60 msgid "Remove all items from the list. Equivalent to ``del a[:]``." -msgstr "刪除 list 中所有項目。這等同於 ``del a[:]`` 。" +msgstr "刪除 list 中所有項目。這等同於 ``del a[:]``。" #: ../../tutorial/datastructures.rst:66 msgid "" @@ -119,15 +119,15 @@ msgstr "" #: ../../tutorial/datastructures.rst:78 msgid "Return the number of times *x* appears in the list." -msgstr "回傳數值為 *x* 在 list 中所出現的次數。" +msgstr "回傳 *x* 在 list 中所出現的次數。" #: ../../tutorial/datastructures.rst:84 msgid "" "Sort the items of the list in place (the arguments can be used for sort " "customization, see :func:`sorted` for their explanation)." msgstr "" -"將 list 中的項目排序。(有參數可以使用來進行客製化的排序,請參考 :func:" -"`sorted` 部分的解釋)" +"將 list 中的項目排序。(可使用引數來進行客製化的排序,請參考 :func:`sorted` " +"部分的解釋)" #: ../../tutorial/datastructures.rst:91 msgid "Reverse the elements of the list in place." @@ -135,7 +135,7 @@ msgstr "將 list 中的項目前後順序反過來。" #: ../../tutorial/datastructures.rst:97 msgid "Return a shallow copy of the list. Equivalent to ``a[:]``." -msgstr "回傳一個淺複製 (shallow copy) 的 list 。等同於 ``a[:]``。" +msgstr "回傳一個淺複製 (shallow copy) 的 list。等同於 ``a[:]``。" #: ../../tutorial/datastructures.rst:100 msgid "An example that uses most of the list methods::" @@ -151,9 +151,9 @@ msgid "" "default ``None``. [1]_ This is a design principle for all mutable data " "structures in Python." msgstr "" -"你可能會注意到一些方法,像是 ``insert`` 、 ``remove`` 或者是 ``sort`` ,並不" -"會印出回傳的值,事實上,他們回傳預設值 ``None`` [1]_。這是一個用於 Python 中" -"所有可變資料結構的設計法則。" +"你可能會注意到一些方法,像是 ``insert``、``remove`` 或者是 ``sort``,並沒有印" +"出回傳值,事實上,他們回傳預設值 ``None`` [1]_。這是一個用於 Python 中所有可" +"變資料結構的設計法則。" #: ../../tutorial/datastructures.rst:128 msgid "" @@ -163,6 +163,10 @@ msgid "" "types. Also, there are some types that don't have a defined ordering " "relation. For example, ``3+4j < 5+7j`` isn't a valid comparison." msgstr "" +"另外你可能也會發現,不是所有資料都可以被排序或比較。例如,``[None, 'hello', " +"10]`` 就不可排序,因為整數不能與字串比較,而 *None* 不能與其他型別比較。有些" +"型別根本就沒有被定義彼此之間的大小順序,例如,``3+4j < 5+7j`` 就是一個無效的" +"比較。" #: ../../tutorial/datastructures.rst:139 msgid "Using Lists as Stacks" @@ -205,8 +209,8 @@ msgid "" "To implement a queue, use :class:`collections.deque` which was designed to " "have fast appends and pops from both ends. For example::" msgstr "" -"如果要實作 queue,請使用 :class:`collections.deque` ,其被設計成能快速的從頭" -"尾兩端加入和取出。例如:\n" +"如果要實作 queue,請使用 :class:`collections.deque`\\ ,其被設計成能快速的從" +"頭尾兩端加入和取出。例如:\n" "\n" "::" @@ -221,10 +225,9 @@ msgid "" "operations applied to each member of another sequence or iterable, or to " "create a subsequence of those elements that satisfy a certain condition." msgstr "" -"List Comprehension(串列綜合運算)讓你可以用簡潔的方法創建 list。常見的應用是" -"基於一個 list 或 iterable(可列舉物件),將每一個元素經過某個運算的結果串接起" -"來成為一個新的 list 。或是創建一個 list 的子序列,其每一個元素皆滿足一個特定" -"的條件。" +"List comprehension(串列綜合運算)讓你可以用簡潔的方法創建 list。常見的應用是" +"基於一個序列或 iterable(可疊代物件),將每一個元素經過某個運算的結果串接起來" +"成為新的 list,或是創建一個子序列,其每一個元素皆滿足一個特定的條件。" #: ../../tutorial/datastructures.rst:204 msgid "For example, assume we want to create a list of squares, like::" @@ -239,8 +242,8 @@ msgid "" "exists after the loop completes. We can calculate the list of squares " "without any side effects using::" msgstr "" -"注意這是創建(或複寫)一個變數叫 ``x`` 其在迴圈結束後仍然存在。我們可以這樣產" -"生平方串列而不造成任何 side effects(副作用):\n" +"注意這是創建(或覆寫)一個變數叫 ``x``,其在迴圈結束後仍然存在。我們可以這樣" +"產生平方串列而不造成任何 side effects(副作用):\n" "\n" "::" @@ -256,7 +259,6 @@ msgid "which is more concise and readable." msgstr "這樣更簡潔和易讀。" #: ../../tutorial/datastructures.rst:225 -#, fuzzy msgid "" "A list comprehension consists of brackets containing an expression followed " "by a :keyword:`!for` clause, then zero or more :keyword:`!for` or :keyword:`!" @@ -265,18 +267,18 @@ msgid "" "which follow it. For example, this listcomp combines the elements of two " "lists if they are not equal::" msgstr "" -"一個 list comprehension 的組成,是包含著一個 expression(運算式)和一個 :" -"keyword:`for` 語句,再接著零個或多個 :keyword:`for` 或 :keyword:`if` 語句的一" -"對方括號。結果會是一個新的串列,內容是在接著的 :keyword:`for` 和 :keyword:" -"`if` 語句的環境下,執行前面 expression 的結果。例如,這個 list comprehension " -"是由兩個串列中互相不同的元素組合所組成:\n" +"一個 list comprehension 的組成,是在一對方括號內,放入一個 expression(運算" +"式)、一個 :keyword:`!for` 子句、再接著零個或多個 :keyword:`!for` 或 :" +"keyword:`!if` 子句。結果會是一個新的 list,內容是在後面的 :keyword:`!for` " +"和 :keyword:`!if` 子句情境下,對前面運算式求值的結果。例如,這個 list " +"comprehension 組合了兩個 list 中彼此相異的元素:\n" "\n" "::" #: ../../tutorial/datastructures.rst:235 msgid "and it's equivalent to::" msgstr "" -"而這和下者相同:\n" +"而它就等於:\n" "\n" "::" @@ -291,8 +293,8 @@ msgid "" "If the expression is a tuple (e.g. the ``(x, y)`` in the previous example), " "it must be parenthesized. ::" msgstr "" -"如果 expression 是一個 tuple(例如上面例子中的 ``(x, y)``),它必須加上小括" -"弧:\n" +"如果 expression 是一個 tuple(例如上面例子中的 ``(x, y)``),它必須加上括" +"號:\n" "\n" "::" @@ -300,7 +302,7 @@ msgstr "" msgid "" "List comprehensions can contain complex expressions and nested functions::" msgstr "" -"List comprehensions 可以含有複雜的 expression 和巢狀的函式呼叫:\n" +"List comprehensions 可以含有複雜的 expression 和巢狀的函式:\n" "\n" "::" @@ -313,8 +315,8 @@ msgid "" "The initial expression in a list comprehension can be any arbitrary " "expression, including another list comprehension." msgstr "" -"最初放在 list comprehesion 中的 expression 可以是任何形式的 expression,包括" -"再寫一個 list comprehension。" +"在 list comprehesion 中開頭的 expression 可以是任何形式的 expression,包括再" +"寫一個 list comprehension。" #: ../../tutorial/datastructures.rst:292 msgid "" @@ -335,16 +337,15 @@ msgid "" "context of the :keyword:`for` that follows it, so this example is equivalent " "to::" msgstr "" -"如同我們在上一節看到的,此巢狀的 list comprehension 為一個 list comprehension" -"在 :keyword:`for` 之前先被計算,接著再作一次 list comprehension,所以,這個例" -"子和下者相同:\n" +"如同我們在上一節看到的,此巢狀的 list comprehension 會依據後面的 :keyword:" +"`for` 環境被求值,所以這個例子就等於:\n" "\n" "::" #: ../../tutorial/datastructures.rst:317 msgid "which, in turn, is the same as::" msgstr "" -"因此,也和下者相同:\n" +"而它也和這一段相同:\n" "\n" "::" @@ -361,15 +362,13 @@ msgstr "" #: ../../tutorial/datastructures.rst:336 msgid "" "See :ref:`tut-unpacking-arguments` for details on the asterisk in this line." -msgstr "關於星號的更多細節,請參考 :ref:`tut-unpacking-arguments` 。" +msgstr "關於星號的更多細節,請參考\\ :ref:`tut-unpacking-arguments`\\ 。" #: ../../tutorial/datastructures.rst:341 -#, fuzzy msgid "The :keyword:`!del` statement" -msgstr ":keyword:`del` 陳述式" +msgstr ":keyword:`!del` 陳述式" #: ../../tutorial/datastructures.rst:343 -#, fuzzy msgid "" "There is a way to remove an item from a list given its index instead of its " "value: the :keyword:`del` statement. This differs from the :meth:`pop` " @@ -377,17 +376,17 @@ msgid "" "used to remove slices from a list or clear the entire list (which we did " "earlier by assignment of an empty list to the slice). For example::" msgstr "" -"有一個方法可以藉由索引而不是值來刪除 list 中的項: :keyword:`del` 陳述式。這" -"和 :meth:`pop` 方法傳回一個值不同, :keyword:`del` 陳述式可以用來刪除 list 中" -"的片段或者清空整個 list(我們之前藉由指派一個空的 list 給想刪除的片段來完成這" -"件事)。例如:\n" +"有一個方法可以藉由索引而不是值來刪除 list 中的項目:\\ :keyword:`del` 陳述" +"式。這和 :meth:`pop` method 傳回一個值不同,\\ :keyword:`!del` 陳述式可以用來" +"刪除 list 中的片段或者清空整個 list(我們之前藉由指派一個空的 list 給想刪除的" +"片段來完成這件事)。例如:\n" "\n" "::" #: ../../tutorial/datastructures.rst:360 msgid ":keyword:`del` can also be used to delete entire variables::" msgstr "" -":keyword:`del` 也可以用來刪除變數:\n" +":keyword:`del` 也可以用來刪除整個變數:\n" "\n" "::" @@ -411,10 +410,10 @@ msgid "" "data types may be added. There is also another standard sequence data type: " "the *tuple*." msgstr "" -"我們看到 lists 和 strings 有許多共同的特性,像是索引操作 (indexing) 以及切片" -"操作 (slicing) 。他們是 *序列* 資料結構中的兩個例子(請參考 :ref:" -"`typesseq` )。由於 Python 是個持續發展中的語言,未來可能還會有其他的序列資料" -"結構加入。接著要介紹是下一個標準序列資料結構: *tuple* 。" +"我們看到 list 和字串 (string) 有許多共同的特性,像是索引操作 (indexing) 以及" +"切片操作 (slicing) 。他們是\\ *序列*\\ 資料類型中的兩個例子(請參考\\ :ref:" +"`typesseq`\\ )。由於 Python 是個持續發展中的語言,未來可能還會有其他的序列資" +"料類型加入。接著要介紹是下一個標準序列資料類型:\\ *tuple*\\ 。" #: ../../tutorial/datastructures.rst:379 msgid "" @@ -435,9 +434,8 @@ msgid "" msgstr "" "如同我們看到的,被輸出的 tuple 總是以括號包著,如此巢狀的 tuple 才能被正確的" "直譯 (interpret);他們可以是以被括號包著或不被包著的方式當作輸入,雖然括號的" -"使用常常是有其必要的(譬如此 tuple 是一個較大的陳述式的一部分)。指派東西給 " -"tuple 中個別的項是不行的,但是可以在 tuple 中放入含有可變項的物件,譬如 " -"list 。" +"使用常常是有其必要的(譬如此 tuple 是一個較大的運算式的一部分)。指派東西給 " +"tuple 中的個別項目是不行的,但是可以建立含有可變物件(譬如 list)的 tuple。" #: ../../tutorial/datastructures.rst:408 msgid "" @@ -450,11 +448,11 @@ msgid "" "iterating over the list." msgstr "" "雖然 tuple 和 list 看起來很類似,但是他們通常用在不同的情況與不同目的。 " -"tuple 是 :term:`immutable` (不可變的),通常儲存異質的序列元素,並可經由拆解" -"(unpacking) (請參考本節後段)或索引 (indexing) 來存取(或者在使用 :func:" -"`namedtuples ` 的時候藉由屬性 (attribute) 來存取)。 " -"list 是 :term:`mutable` (可變的),其元素通常是同質的且可藉由迭代整個串列來" -"存取。" +"tuple 是 :term:`immutable`\\ (不可變的),通常儲存異質的元素序列,並可經由拆" +"解 (unpacking)(請參考本節後段)或索引 (indexing) 來存取(或者在使用 :func:" +"`namedtuples ` 的時候藉由屬性 (attribute) 來存取)。" +"List 是 :term:`mutable`\\ (可變的),其元素通常是同質的且可藉由疊代整個 " +"list 來存取。" #: ../../tutorial/datastructures.rst:416 msgid "" @@ -466,7 +464,8 @@ msgid "" msgstr "" "一個特別的議題是,關於創建一個含有 0 個或 1 個項目的 tuple:語法上會採納一些" "奇怪的用法。空的 tuple 藉由一對空括號來創建;含有一個項目的 tuple 經由一個值" -"加上一個逗點來創建(不需要用括號把一個單一的值包住)。醜,但有效率。例如:\n" +"加上一個逗點來創建(用括號把一個單一的值包住是不夠的)。醜,但有效率。例" +"如:\n" "\n" "::" @@ -476,8 +475,8 @@ msgid "" "packing*: the values ``12345``, ``54321`` and ``'hello!'`` are packed " "together in a tuple. The reverse operation is also possible::" msgstr "" -"陳述式 ``t = 12345, 54321, 'hello!'`` 就是一個 *tuple packing* 的例子: " -"``12345`` , ``54321`` 和 ``'hello!'`` 一起被放進 tuple 裡。反向操作也可" +"陳述式 ``t = 12345, 54321, 'hello!'`` 就是一個 *tuple packing* 的例子:\\ " +"``12345``,\\ ``54321`` 和 ``'hello!'`` 一起被放進 tuple 裡。反向操作也可" "以:\n" "\n" "::" @@ -490,8 +489,8 @@ msgid "" "in the sequence. Note that multiple assignment is really just a combination " "of tuple packing and sequence unpacking." msgstr "" -"這個正是我們所說序列拆解 (*sequence unpacking*) ,可運用在任何位在等號右邊的" -"序列。序列拆解要求等號左邊的變數數量必須與等號右邊的序列中的元素數量相同。注" +"這個正是我們所說序列拆解 (*sequence unpacking*),可運用在任何位在等號右邊的序" +"列。序列拆解要求等號左邊的變數數量必須與等號右邊的序列中的元素數量相同。注" "意,多重指派就只是 tuple packing 和序列拆解的結合而已。" #: ../../tutorial/datastructures.rst:447 @@ -506,9 +505,9 @@ msgid "" "mathematical operations like union, intersection, difference, and symmetric " "difference." msgstr "" -"Python 也包含了一種用在集合 (*sets*) 的資料結構。一個 set 是一組無序且沒有重" -"複的元素。基本的使用方式包括了成員測試和消除重複項。 Set 物件也支援聯集,交" -"集,差集和互斥等數學操作。" +"Python 也包含了一種用在 *set*\\ (集合)的資料類型。一個 set 是一組無序且沒有" +"重複的元素。基本的使用方式包括了成員測試和消除重複元素。 Set 物件也支援聯集、" +"交集、差集和互斥等數學運算。" #: ../../tutorial/datastructures.rst:454 msgid "" @@ -517,9 +516,9 @@ msgid "" "creates an empty dictionary, a data structure that we discuss in the next " "section." msgstr "" -"大括號或 :func:`set` 函式都可以用來創建 set 。注意:要創建一個空的 set ,我們" -"必須使用 ``set()`` 而不是 ``{}`` ;後者會創建一個空的 dictionary ,一種我們將" -"在下一節討論的資料結構。" +"大括號或 :func:`set` 函式都可以用來創建 set。注意:要創建一個空的 set,你必須" +"使用 ``set()`` 而不是 ``{}``\\ ;後者會創建一個空的 dictionary,一種我們將在" +"下一節討論的資料結構。" #: ../../tutorial/datastructures.rst:458 msgid "Here is a brief demonstration::" @@ -533,8 +532,8 @@ msgid "" "Similarly to :ref:`list comprehensions `, set comprehensions " "are also supported::" msgstr "" -"和 :ref:`list comprehensions ` 類似,也有 set comprehensions " -"(集合綜合運算):\n" +"和 :ref:`list comprehensions ` 類似,也有 set " +"comprehensions(集合綜合運算):\n" "\n" "::" @@ -555,14 +554,14 @@ msgid "" "in place using index assignments, slice assignments, or methods like :meth:" "`append` and :meth:`extend`." msgstr "" -"下一個常用的 python 內建資料結構為 *dictionary* (請參考 :ref:" -"`typesmapping` )。 Dictionary 有時被稱為 \"關聯記憶體\" (associative " -"memories) 或 \"關聯矩陣\" (associative arrays) 。不像序列是由一個範圍內的數字" -"當作索引, dictionary 是由 *key* (鍵)來當索引, key 可以是任何不可變的型" -"態;字串和數字都可以當作 key 。 Tuple 也可以當作 key 如果他們只含有字串、數字" -"或 tuple;若一個 tuple 直接或間接地含有任何可變的物件,它就不能當作 key 。我" -"們無法使用 list 當作 key ,因為 list 可以經由索引操作、切片操作或是方法像是 :" -"meth:`append` 和 :meth:`extend` 來修改。" +"下一個常用的 Python 內建資料類型為 *dictionary*\\ (請參考\\ :ref:" +"`typesmapping`\\ )。 Dictionary 有時被稱為 \"關聯記憶體\" (associative " +"memories) 或 \"關聯陣列\" (associative arrays)。不像序列是由一個範圍內的數字" +"當作索引,dictionary 是由\\ *鍵* (key) 來當索引,鍵可以是任何不可變的類型;字" +"串和數字都可以當作鍵。Tuple 也可以當作鍵,如果他們只含有字串、數字或 tuple;" +"若一個 tuple 直接或間接地含有任何可變的物件,它就不能當作鍵。你無法使用 list " +"當作鍵,因為 list 可以經由索引指派 (index assignment)、切片指派 (slice " +"assignment) 或是像 :meth:`append` 和 :meth:`extend` 等 method 被修改。" #: ../../tutorial/datastructures.rst:507 msgid "" @@ -572,10 +571,10 @@ msgid "" "of key:value pairs within the braces adds initial key:value pairs to the " "dictionary; this is also the way dictionaries are written on output." msgstr "" -"思考 dict 最好的方式是把它想成是一組鍵值對 (*key: value* pair) 的集合,其中 " -"key 在同一個 dictionary(字典)裡必須是獨一無二的。使用一對大括號可創建一個空" -"的字典 :``{}``。將一串由逗號分隔的鍵值對置於大括號則可初始化字典。這同樣也是" -"字典輸出時的格式。" +"思考 dictionary 最好的方式是把它想成是一組\\ *鍵值*\\ 對 (*key: value* pair) " +"的 set,其中鍵在同一個 dictionary 裡必須是獨一無二的。使用一對大括號可創建一" +"個空的 dictionary:\\ ``{}``\\ 。將一串由逗號分隔的鍵值對置於大括號則可初始化" +"字典的鍵值對。這同樣也是字典輸出時的格式。" #: ../../tutorial/datastructures.rst:513 msgid "" @@ -585,9 +584,9 @@ msgid "" "the old value associated with that key is forgotten. It is an error to " "extract a value using a non-existent key." msgstr "" -"Dict 主要的操作為藉由鍵來儲存一個值並且可藉由該鍵來取出該值。也可以使用 " -"``del`` 來刪除鍵值對。如果我們使用用過的鍵來儲存,該鍵所對應的較舊的值會被覆" -"蓋。使用不存在的鍵來取出值會造成錯誤。" +"Dictionary 主要的操作為藉由鍵來儲存一個值並且可藉由該鍵來取出該值。也可以使" +"用 ``del`` 來刪除鍵值對。如果我們使用用過的鍵來儲存,該鍵所對應的較舊的值會被" +"覆蓋。使用不存在的鍵來取出值會造成錯誤。" #: ../../tutorial/datastructures.rst:519 msgid "" @@ -596,14 +595,14 @@ msgid "" "``sorted(d)`` instead). To check whether a single key is in the dictionary, " "use the :keyword:`in` keyword." msgstr "" -"對字典使用 ``list(d)`` 會得到一個包含該字典所有鍵(key)的 list,其排列順序為" -"插入時的順序。(若想要排序,則使用 ``sorted(d)`` 代替即可)。如果想確認一個鍵" -"是否已存在於字典中,可使用關鍵字 :keyword:`in` 。" +"對 dictionary 使用 ``list(d)`` 會得到一個包含該字典所有鍵的 list,其排列順序" +"為插入時的順序。(若想要排序,則使用 ``sorted(d)`` 代替即可)。如果想確認一個" +"鍵是否已存在於字典中,可使用關鍵字 :keyword:`in`\\ 。" #: ../../tutorial/datastructures.rst:524 msgid "Here is a small example using a dictionary::" msgstr "" -"這是個使用一個字典的簡單範例:\n" +"這是個使用一個 dictionary 的簡單範例:\n" "\n" "::" @@ -612,7 +611,7 @@ msgid "" "The :func:`dict` constructor builds dictionaries directly from sequences of " "key-value pairs::" msgstr "" -"函式 :func:`dict` 可直接透過一串鍵值對序列來創建 dict:\n" +"函式 :func:`dict` 可直接透過一串鍵值對序列來創建 dictionary:\n" "\n" "::" @@ -621,7 +620,7 @@ msgid "" "In addition, dict comprehensions can be used to create dictionaries from " "arbitrary key and value expressions::" msgstr "" -"此外, dict comprehensions 也可以透過鍵與值的陳述式來創建 dict :\n" +"此外,dict comprehensions 也可以透過任意鍵與值的運算式來創建 dictionary :\n" "\n" "::" @@ -643,8 +642,8 @@ msgid "" "When looping through dictionaries, the key and corresponding value can be " "retrieved at the same time using the :meth:`items` method. ::" msgstr "" -"當對 dict 作迴圈時,鍵以及其對應的值可以藉由使用 :meth:`items` 方法來同時取" -"得:\n" +"當對 dictionary 作迴圈時,鍵以及其對應的值可以藉由使用 :meth:`items` method " +"來同時取得:\n" "\n" "::" @@ -672,7 +671,7 @@ msgid "" "To loop over a sequence in reverse, first specify the sequence in a forward " "direction and then call the :func:`reversed` function. ::" msgstr "" -"要對序列作反向的迴圈,首先先寫出正向的序列,在對其使用 :func:`reversed` 函" +"要對序列作反向的迴圈,首先先寫出正向的序列,再對其使用 :func:`reversed` 函" "式:\n" "\n" "::" @@ -694,6 +693,10 @@ msgid "" "idiomatic way to loop over unique elements of the sequence in sorted " "order. ::" msgstr "" +"對序列使用 :func:`set` 可去除重複元素。對序列使用 :func:`sorted` 加上 :func:" +"`set`\\ ,則是對經過排序後的非重複元素跑迴圈的慣用方法:\n" +"\n" +"::" #: ../../tutorial/datastructures.rst:640 msgid "" @@ -707,37 +710,36 @@ msgstr "" #: ../../tutorial/datastructures.rst:657 msgid "More on Conditions" -msgstr "更多條件式主題" +msgstr "深入了解條件 (Condition)" #: ../../tutorial/datastructures.rst:659 msgid "" "The conditions used in ``while`` and ``if`` statements can contain any " "operators, not just comparisons." msgstr "" -"使用在 ``while`` 和 ``if`` 內的陳述式可以包含任何運算子,而不是只有比較運算" -"子 (comparisons) 。" +"使用在 ``while`` 和 ``if`` 陳述式的條件句可以包含任何運算子,而不是只有比較運" +"算子 (comparisons) 。" #: ../../tutorial/datastructures.rst:662 msgid "" "The comparison operators ``in`` and ``not in`` check whether a value occurs " "(does not occur) in a sequence. The operators ``is`` and ``is not`` compare " -"whether two objects are really the same object; this only matters for " -"mutable objects like lists. All comparison operators have the same " -"priority, which is lower than that of all numerical operators." +"whether two objects are really the same object. All comparison operators " +"have the same priority, which is lower than that of all numerical operators." msgstr "" -"比較運算子 ``in`` 和 ``not in`` 檢查一個數值是否存在(不存在)於一個序列中。" -"運算子 ``is`` 和 ``not is`` 比較兩個物件是否真的是相同的物件;這對可變物件例" -"如 list 來說很重要。所有的比較運算子優先度都相同且都低於數值運算子。" +"比較運算子 ``in`` 和 ``not in`` 檢查一個值是否存在(不存在)於一個序列中。運" +"算子 ``is`` 和 ``not is`` 比較兩個物件是否真的是相同的物件。所有比較運算子的" +"優先度都相同且都低於數值運算子。" -#: ../../tutorial/datastructures.rst:668 +#: ../../tutorial/datastructures.rst:667 msgid "" "Comparisons can be chained. For example, ``a < b == c`` tests whether ``a`` " "is less than ``b`` and moreover ``b`` equals ``c``." msgstr "" "比較運算是可以串連在一起的。例如, ``a < b == c`` 就是在測試 ``a`` 是否小於 " -"``b`` 和 ``b`` 是否等於 ``c`` 。" +"``b`` 和 ``b`` 是否等於 ``c``\\ 。" -#: ../../tutorial/datastructures.rst:671 +#: ../../tutorial/datastructures.rst:670 msgid "" "Comparisons may be combined using the Boolean operators ``and`` and ``or``, " "and the outcome of a comparison (or of any other Boolean expression) may be " @@ -746,12 +748,13 @@ msgid "" "lowest, so that ``A and not B or C`` is equivalent to ``(A and (not B)) or " "C``. As always, parentheses can be used to express the desired composition." msgstr "" -"比較運算可以結合布林運算子 ``and`` 和 ``or`` ,且一個比較運算的結果(或任何其" -"他布林表達式)可以加上 ``not`` 來否定。這些運算子的優先度都比比較運算子還低," -"其中, ``not`` 的優先度最高, ``or`` 的優先度最低,因此 ``A and not B or C`` " -"等同於 ``(A and (not B)) or C`` 。一如往常,括號可以用來表示任何想要的組合。" +"比較運算可以結合布林運算子 ``and`` 和 ``or``\\ ,且一個比較運算的結果(或任何" +"其他布林運算式)可以加上 ``not`` 來否定。這些運算子的優先度都比比較運算子還" +"低,其中,\\ ``not`` 的優先度最高,\\ ``or`` 的優先度最低,因此 ``A and not " +"B or C`` 等同於 ``(A and (not B)) or C``\\ 。一如往常,括號可以用來表示任何想" +"要的組合。" -#: ../../tutorial/datastructures.rst:678 +#: ../../tutorial/datastructures.rst:677 msgid "" "The Boolean operators ``and`` and ``or`` are so-called *short-circuit* " "operators: their arguments are evaluated from left to right, and evaluation " @@ -760,38 +763,36 @@ msgid "" "expression ``C``. When used as a general value and not as a Boolean, the " "return value of a short-circuit operator is the last evaluated argument." msgstr "" -"布林運算子 ``and`` 和 ``or`` 也被稱為短路 (*short-circuit*) 運算子:會將其引" -"數從左至右進行運算,當結果出現時即結束運算。例如,若 ``A`` 和 ``C`` 為真但 " -"``B`` 為假,則 ``A and B and C`` 的運算並不會執行到 ``C`` 。當運算結果被當成" -"一般數值而非布林值時,短路運算子的回傳值為最後被運算的引數。" +"布林運算子 ``and`` 和 ``or`` 也被稱為\\ *短路 (short-circuit)* 運算子:會將其" +"引數從左至右進行運算,當結果出現時即結束運算。例如,若 ``A`` 和 ``C`` 為真但 " +"``B`` 為假,則 ``A and B and C`` 的運算並不會執行到 ``C``\\ 。當運算結果被當" +"成一般值而非布林值時,短路運算子的回傳值為最後被求值的引數。" -#: ../../tutorial/datastructures.rst:685 +#: ../../tutorial/datastructures.rst:684 msgid "" "It is possible to assign the result of a comparison or other Boolean " "expression to a variable. For example, ::" msgstr "" -"將一個比較運算或其他布林表達式的結果指派給一個變數是可以的。例如:\n" +"將一個比較運算或其他布林運算式的結果指派給一個變數是可以的。例如:\n" "\n" "::" -#: ../../tutorial/datastructures.rst:693 -#, fuzzy +#: ../../tutorial/datastructures.rst:692 msgid "" "Note that in Python, unlike C, assignment inside expressions must be done " "explicitly with the :ref:`walrus operator ` ``:=``. This avoids a common class of problems encountered " "in C programs: typing ``=`` in an expression when ``==`` was intended." msgstr "" -"注意, Python 不像 C 語言,在表達式裡進行指派是不行的。 C 語言的程式設計師可" -"能會抱怨這件事,但這樣做避免了在 C 語言裡常見的一種問題:想要打 ``==`` 卻在表" -"達式裡輸入 ``=`` 。" +"注意,Python 與 C 語言不一樣,在運算式裡進行指派必須外顯地使用\\ :ref:`海象運" +"算子 ` ``:=``\\ 。 這樣做避免" +"了在 C 語言裡常見的一種問題:想要打 ``==`` 卻在運算式裡輸入 ``=``\\ 。" -#: ../../tutorial/datastructures.rst:703 +#: ../../tutorial/datastructures.rst:702 msgid "Comparing Sequences and Other Types" -msgstr "序列和其他資料結構之比較" +msgstr "序列和其他資料類型之比較" -#: ../../tutorial/datastructures.rst:704 -#, fuzzy +#: ../../tutorial/datastructures.rst:703 msgid "" "Sequence objects typically may be compared to other objects with the same " "sequence type. The comparison uses *lexicographical* ordering: first the " @@ -806,17 +807,17 @@ msgid "" "order individual characters. Some examples of comparisons between sequences " "of the same type::" msgstr "" -"序列物件可以拿來和其他相同型態的物件做比較。這種比較使用詞典式順序 " -"(*lexicographical* ordering) :首先比較各自最前面的那項,若不相同,便可決定結" -"果,若相同,則比較下ㄧ項,以此類推,直到其中一個序列完全用完。如果被拿出來比" -"較的兩項本身又是相同的序列型態,則詞典式順序的比較會遞迴處理。如果兩個序列所" -"有的項都相等,則此兩個序列被認為是相等的。如果其中一個序列是另一個的子序列," -"則較短的那個序列為較小的序列。字串的詞典式順序使用 Unicode 的碼位 (code " -"point) 編號來排序個別字元。以下是一些相同序列型態的比較:\n" +"序列物件通常可以拿來和其他相同類型的物件做比較。這種比較使用\\ *詞典式 " +"(lexicographical)* 順序:首先比較各自最前面的那項,若不相同,便可決定結果;若" +"相同,則比較下ㄧ項,以此類推,直到其中一個序列完全用完。如果被拿出來比較的兩" +"項本身又是相同的序列類型,則詞典式比較會遞迴地執行。如果兩個序列所有的項目都" +"相等,則此兩個序列被認為是相等的。如果其中一個序列是另一個的子序列,則較短的" +"那個序列為較小的序列。字串的詞典式順序使用 Unicode 的碼位 (code point) 編號來" +"排序個別字元。以下是一些相同序列類型的比較:\n" "\n" "::" -#: ../../tutorial/datastructures.rst:724 +#: ../../tutorial/datastructures.rst:723 msgid "" "Note that comparing objects of different types with ``<`` or ``>`` is legal " "provided that the objects have appropriate comparison methods. For example, " @@ -824,21 +825,21 @@ msgid "" "equals 0.0, etc. Otherwise, rather than providing an arbitrary ordering, " "the interpreter will raise a :exc:`TypeError` exception." msgstr "" -"注意,若使用 ``<`` 或 ``>`` 來比較不同型態的物件是合法的,表示物件擁有適當的" -"比較方法。例如,混合型數值比較是根據它們數字的值來做比較,所以 0 等於 0.0,等" -"等。否則直譯器會選擇丟出一個 :exc:`TypeError` 錯誤而不是提供一個任意的排序。" +"注意,若使用 ``<`` 或 ``>`` 來比較不同類型的物件是合法的,表示物件擁有適當的" +"比較方法。例如,混合的數值類型是根據它們數值來做比較,所以 0 等於 0.0,等等。" +"否則直譯器會選擇丟出一個 :exc:`TypeError` 錯誤而不是提供一個任意的排序。" -#: ../../tutorial/datastructures.rst:732 +#: ../../tutorial/datastructures.rst:731 msgid "Footnotes" msgstr "註解" -#: ../../tutorial/datastructures.rst:733 +#: ../../tutorial/datastructures.rst:732 msgid "" "Other languages may return the mutated object, which allows method chaining, " "such as ``d->insert(\"a\")->remove(\"b\")->sort();``." msgstr "" -"其他語言可能可以回傳可變的物件並允許方法串連,例如 ``d->insert(\"a\")-" -">remove(\"b\")->sort();`` 。" +"其他語言可以回傳變更後的物件,這就允許 method 的串連,例如 ``d->insert(\"a" +"\")->remove(\"b\")->sort();``\\ 。" #~ msgid "" #~ "Calling ``d.keys()`` will return a :dfn:`dictionary view` object. It "