From 822c98238ff60e1a0f3068aeab5be1ce546d67a7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 12 Jan 2026 12:24:11 +0000 Subject: [PATCH 1/3] sync with cpython 46594d4f --- c-api/apiabiversion.po | 126 +++--- library/enum.po | 387 +++++++++--------- library/functions.po | 863 +++++++++++++++++++++-------------------- 3 files changed, 701 insertions(+), 675 deletions(-) diff --git a/c-api/apiabiversion.po b/c-api/apiabiversion.po index ac7a67f22c8..385421a8f37 100644 --- a/c-api/apiabiversion.po +++ b/c-api/apiabiversion.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-08 15:25+0800\n" +"POT-Creation-Date: 2026-01-12 12:22+0000\n" "PO-Revision-Date: 2022-01-24 22:34+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -35,7 +35,8 @@ msgid "" "for the version used at **run time**." msgstr "" "CPython 透過以下巨集 (macro) 公開其版本號。請注意,對應到的是\\ **建置 " -"(built)** 所用到的版本。關於\\ **run time** 所使用的版本,請見 :c:var:`Py_Version`。" +"(built)** 所用到的版本。關於\\ **run time** 所使用的版本,請見 :c:var:" +"`Py_Version`。" #: ../../c-api/apiabiversion.rst:17 msgid "" @@ -68,207 +69,214 @@ msgstr "在 ``3.4.1a2`` 中的 ``2``。零則為最終發布版本。" #: ../../c-api/apiabiversion.rst:43 msgid "" -"The Python version number encoded in a single integer. " -"See :c:func:`Py_PACK_FULL_VERSION` for the encoding details." -msgstr "被編碼為單一整數的 Python 版本號。詳見 :c:func:`Py_PACK_FULL_VERSION` 以了解編碼詳細資訊。" +"The Python version number encoded in a single integer. See :c:func:" +"`Py_PACK_FULL_VERSION` for the encoding details." +msgstr "" +"被編碼為單一整數的 Python 版本號。詳見 :c:func:`Py_PACK_FULL_VERSION` 以了解" +"編碼詳細資訊。" #: ../../c-api/apiabiversion.rst:46 msgid "" "Use this for numeric comparisons, for example, ``#if PY_VERSION_HEX >= ...``." msgstr "使用它進行數值比較,例如 ``#if PY_VERSION_HEX >= ...``。" -#: ../../c-api/apiabiversion.rst:51 +#: ../../c-api/apiabiversion.rst:49 +msgid "These macros are defined in :source:`Include/patchlevel.h`." +msgstr "" + +#: ../../c-api/apiabiversion.rst:53 msgid "Run-time version" msgstr "" -#: ../../c-api/apiabiversion.rst:55 +#: ../../c-api/apiabiversion.rst:57 msgid "" -"The Python runtime version number encoded in a single constant integer. " -"See :c:func:`Py_PACK_FULL_VERSION` for the encoding details. This contains " -"the Python version used at run time." +"The Python runtime version number encoded in a single constant integer. See :" +"c:func:`Py_PACK_FULL_VERSION` for the encoding details. This contains the " +"Python version used at run time." msgstr "" -"編碼為單個常數整數的 Python runtime 版本號。詳見 :c:func:`Py_PACK_FULL_VERSION` " -"以了解編碼詳細資訊。這包含在 runtime 使用的 Python 版本。" +"編碼為單個常數整數的 Python runtime 版本號。詳見 :c:func:" +"`Py_PACK_FULL_VERSION` 以了解編碼詳細資訊。這包含在 runtime 使用的 Python 版" +"本。" -#: ../../c-api/apiabiversion.rst:59 +#: ../../c-api/apiabiversion.rst:61 msgid "" "Use this for numeric comparisons, for example, ``if (Py_Version >= ...)``." msgstr "使用它進行數值比較,例如 ``if (Py_Version >= ...)``。" -#: ../../c-api/apiabiversion.rst:65 +#: ../../c-api/apiabiversion.rst:67 msgid "Bit-packing macros" msgstr "" -#: ../../c-api/apiabiversion.rst:69 +#: ../../c-api/apiabiversion.rst:71 msgid "" "Return the given version, encoded as a single 32-bit integer with the " "following structure:" msgstr "" -#: ../../c-api/apiabiversion.rst:75 +#: ../../c-api/apiabiversion.rst:77 msgid "Argument" msgstr "引數" -#: ../../c-api/apiabiversion.rst:73 +#: ../../c-api/apiabiversion.rst:75 msgid "No. of bits" msgstr "" -#: ../../c-api/apiabiversion.rst:75 +#: ../../c-api/apiabiversion.rst:77 msgid "Bit mask" msgstr "" -#: ../../c-api/apiabiversion.rst:75 +#: ../../c-api/apiabiversion.rst:77 msgid "Bit shift" msgstr "" -#: ../../c-api/apiabiversion.rst:73 +#: ../../c-api/apiabiversion.rst:75 msgid "Example values" msgstr "" -#: ../../c-api/apiabiversion.rst:75 ../../c-api/apiabiversion.rst:93 +#: ../../c-api/apiabiversion.rst:77 ../../c-api/apiabiversion.rst:95 msgid "``3.4.1a2``" msgstr "``3.4.1a2``" -#: ../../c-api/apiabiversion.rst:75 ../../c-api/apiabiversion.rst:95 +#: ../../c-api/apiabiversion.rst:77 ../../c-api/apiabiversion.rst:97 msgid "``3.10.0``" msgstr "``3.10.0``" -#: ../../c-api/apiabiversion.rst:77 +#: ../../c-api/apiabiversion.rst:79 msgid "*major*" msgstr "*major*" -#: ../../c-api/apiabiversion.rst:77 ../../c-api/apiabiversion.rst:79 -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:79 ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:83 msgid "8" msgstr "8" -#: ../../c-api/apiabiversion.rst:77 +#: ../../c-api/apiabiversion.rst:79 msgid "``0xFF000000``" msgstr "``0xFF000000``" -#: ../../c-api/apiabiversion.rst:77 +#: ../../c-api/apiabiversion.rst:79 msgid "24" msgstr "24" -#: ../../c-api/apiabiversion.rst:77 +#: ../../c-api/apiabiversion.rst:79 msgid "``0x03``" msgstr "``0x03``" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:81 msgid "*minor*" msgstr "" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:81 msgid "``0x00FF0000``" msgstr "``0x00FF0000``" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:81 msgid "16" msgstr "16" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:81 msgid "``0x04``" msgstr "``0x04``" -#: ../../c-api/apiabiversion.rst:79 +#: ../../c-api/apiabiversion.rst:81 msgid "``0x0A``" msgstr "``0x0A``" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:83 msgid "*micro*" msgstr "*micro*" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:83 msgid "``0x0000FF00``" msgstr "``0x0000FF00``" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:83 msgid "``0x01``" msgstr "``0x01``" -#: ../../c-api/apiabiversion.rst:81 +#: ../../c-api/apiabiversion.rst:83 msgid "``0x00``" msgstr "``0x00``" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:85 msgid "*release_level*" msgstr "*release_level*" -#: ../../c-api/apiabiversion.rst:83 ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:85 ../../c-api/apiabiversion.rst:87 msgid "4" msgstr "4" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:85 msgid "``0x000000F0``" msgstr "``0x000000F0``" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:85 msgid "``0xA``" msgstr "``0xA``" -#: ../../c-api/apiabiversion.rst:83 +#: ../../c-api/apiabiversion.rst:85 msgid "``0xF``" msgstr "``0xF``" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:87 msgid "*release_serial*" msgstr "*release_serial*" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:87 msgid "``0x0000000F``" msgstr "``0x0000000F``" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:87 msgid "0" msgstr "0" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:87 msgid "``0x2``" msgstr "``0x2``" -#: ../../c-api/apiabiversion.rst:85 +#: ../../c-api/apiabiversion.rst:87 msgid "``0x0``" msgstr "``0x0``" -#: ../../c-api/apiabiversion.rst:88 +#: ../../c-api/apiabiversion.rst:90 msgid "For example:" msgstr "例如:" -#: ../../c-api/apiabiversion.rst:91 +#: ../../c-api/apiabiversion.rst:93 msgid "Version" msgstr "版本" -#: ../../c-api/apiabiversion.rst:91 +#: ../../c-api/apiabiversion.rst:93 msgid "``Py_PACK_FULL_VERSION`` arguments" msgstr "``Py_PACK_FULL_VERSION`` 引數" -#: ../../c-api/apiabiversion.rst:91 +#: ../../c-api/apiabiversion.rst:93 msgid "Encoded version" msgstr "" -#: ../../c-api/apiabiversion.rst:93 +#: ../../c-api/apiabiversion.rst:95 msgid "``(3, 4, 1, 0xA, 2)``" msgstr "``(3, 4, 1, 0xA, 2)``" -#: ../../c-api/apiabiversion.rst:93 +#: ../../c-api/apiabiversion.rst:95 msgid "``0x030401a2``" msgstr "``0x030401a2``" -#: ../../c-api/apiabiversion.rst:95 +#: ../../c-api/apiabiversion.rst:97 msgid "``(3, 10, 0, 0xF, 0)``" msgstr "``(3, 10, 0, 0xF, 0)``" -#: ../../c-api/apiabiversion.rst:95 +#: ../../c-api/apiabiversion.rst:97 msgid "``0x030a00f0``" msgstr "``0x030a00f0``" -#: ../../c-api/apiabiversion.rst:98 +#: ../../c-api/apiabiversion.rst:100 msgid "" "Out-of range bits in the arguments are ignored. That is, the macro can be " "defined as:" msgstr "" -#: ../../c-api/apiabiversion.rst:101 +#: ../../c-api/apiabiversion.rst:103 msgid "" "#ifndef Py_PACK_FULL_VERSION\n" "#define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \\\n" @@ -288,13 +296,13 @@ msgstr "" " (((SERIAL) & 0xf) << 0))\n" "#endif" -#: ../../c-api/apiabiversion.rst:112 +#: ../../c-api/apiabiversion.rst:114 msgid "" "``Py_PACK_FULL_VERSION`` is primarily a macro, intended for use in ``#if`` " "directives, but it is also available as an exported function." msgstr "" -#: ../../c-api/apiabiversion.rst:119 +#: ../../c-api/apiabiversion.rst:121 msgid "" "Equivalent to ``Py_PACK_FULL_VERSION(major, minor, 0, 0, 0)``. The result " "does not correspond to any Python release, but is useful in numeric " diff --git a/library/enum.po b/library/enum.po index 7445c2760ef..e4e123e8a03 100644 --- a/library/enum.po +++ b/library/enum.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-12-19 00:15+0000\n" +"POT-Creation-Date: 2026-01-12 12:22+0000\n" "PO-Revision-Date: 2024-12-21 13:50+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -330,11 +330,23 @@ msgstr ":func:`show_flag_values`" msgid "Return a list of all power-of-two integers contained in a flag." msgstr "回傳旗標 (flag) 裡包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:157 +#: ../../library/enum.rst:156 +#, fuzzy +msgid ":func:`enum.bin`" +msgstr ":func:`member`" + +#: ../../library/enum.rst:158 ../../library/enum.rst:1046 +msgid "" +"Like built-in :func:`bin`, except negative values are represented in two's " +"complement, and the leading bit always indicates sign (``0`` implies " +"positive, ``1`` implies negative)." +msgstr "" + +#: ../../library/enum.rst:163 msgid "``Flag``, ``IntFlag``, ``auto``" msgstr "``Flag``, ``IntFlag``, ``auto``" -#: ../../library/enum.rst:158 +#: ../../library/enum.rst:164 msgid "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" @@ -342,15 +354,15 @@ msgstr "" "``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, " "``member``, ``nonmember``, ``global_enum``, ``show_flag_values``" -#: ../../library/enum.rst:159 +#: ../../library/enum.rst:165 msgid "``EnumDict``" msgstr "``EnumDict``" -#: ../../library/enum.rst:164 +#: ../../library/enum.rst:170 msgid "Data Types" msgstr "資料型別" -#: ../../library/enum.rst:169 +#: ../../library/enum.rst:175 msgid "" "*EnumType* is the :term:`metaclass` for *enum* enumerations. It is possible " "to subclass *EnumType* -- see :ref:`Subclassing EnumType `。" -#: ../../library/enum.rst:173 +#: ../../library/enum.rst:179 msgid "" "``EnumType`` is responsible for setting the correct :meth:`!__repr__`, :meth:" "`!__str__`, :meth:`!__format__`, and :meth:`!__reduce__` methods on the " @@ -370,17 +382,17 @@ msgstr "" "`!__str__`、:meth:`!__format__` 及 :meth:`!__reduce__` 方法,以及建立列舉成" "員、正確處理重複、提供列舉類別的疊代等等。" -#: ../../library/enum.rst:180 +#: ../../library/enum.rst:186 msgid "" "Before 3.11 ``EnumType`` was called ``EnumMeta``, which is still available " "as an alias." msgstr "在 3.11 之前,``EnumType`` 稱作 ``EnumMeta``,其目前仍可作為別名使用。" -#: ../../library/enum.rst:184 +#: ../../library/enum.rst:190 msgid "This method is called in two different ways:" msgstr "這個方法可以用兩種不同的方式呼叫:" -#: ../../library/enum.rst:186 +#: ../../library/enum.rst:192 msgid "to look up an existing member:" msgstr "查詢已存在的成員:" @@ -388,7 +400,7 @@ msgstr "查詢已存在的成員:" msgid "cls" msgstr "cls" -#: ../../library/enum.rst:188 ../../library/enum.rst:194 +#: ../../library/enum.rst:194 ../../library/enum.rst:200 msgid "The enum class being called." msgstr "所呼叫的列舉類別。" @@ -396,17 +408,17 @@ msgstr "所呼叫的列舉類別。" msgid "value" msgstr "value" -#: ../../library/enum.rst:189 +#: ../../library/enum.rst:195 msgid "The value to lookup." msgstr "要查詢的值。" -#: ../../library/enum.rst:191 +#: ../../library/enum.rst:197 msgid "" "to use the ``cls`` enum to create a new enum (only if the existing enum does " "not have any members):" msgstr "使用 ``cls`` 列舉來建立新列舉(只有在現有列舉沒有任何成員時)" -#: ../../library/enum.rst:195 +#: ../../library/enum.rst:201 msgid "The name of the new Enum to create." msgstr "要建立的新列舉的名稱。" @@ -414,7 +426,7 @@ msgstr "要建立的新列舉的名稱。" msgid "names" msgstr "names" -#: ../../library/enum.rst:196 +#: ../../library/enum.rst:202 msgid "The names/values of the members for the new Enum." msgstr "新列舉的成員的名稱/值。" @@ -422,7 +434,7 @@ msgstr "新列舉的成員的名稱/值。" msgid "module" msgstr "module" -#: ../../library/enum.rst:197 +#: ../../library/enum.rst:203 msgid "The name of the module the new Enum is created in." msgstr "新列舉要建立在哪個模組名稱下。" @@ -430,7 +442,7 @@ msgstr "新列舉要建立在哪個模組名稱下。" msgid "qualname" msgstr "qualname" -#: ../../library/enum.rst:198 +#: ../../library/enum.rst:204 msgid "The actual location in the module where this Enum can be found." msgstr "這個列舉在模組裡實際上的位置。" @@ -438,7 +450,7 @@ msgstr "這個列舉在模組裡實際上的位置。" msgid "type" msgstr "type" -#: ../../library/enum.rst:199 +#: ../../library/enum.rst:205 msgid "A mix-in type for the new Enum." msgstr "新列舉的混合型別。" @@ -446,7 +458,7 @@ msgstr "新列舉的混合型別。" msgid "start" msgstr "start" -#: ../../library/enum.rst:200 +#: ../../library/enum.rst:206 msgid "The first integer value for the Enum (used by :class:`auto`)." msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" @@ -454,16 +466,16 @@ msgstr "列舉的第一個整數值(由 :class:`auto` 所使用)" msgid "boundary" msgstr "boundary" -#: ../../library/enum.rst:201 +#: ../../library/enum.rst:207 msgid "" "How to handle out-of-range values from bit operations (:class:`Flag` only)." msgstr "在位元操作時怎麼處理範圍外的值(只有 :class:`Flag` 會用到)" -#: ../../library/enum.rst:205 +#: ../../library/enum.rst:211 msgid "Returns ``True`` if member belongs to the ``cls``::" msgstr "如果 member 屬於 ``cls`` 則回傳 ``True``: ::" -#: ../../library/enum.rst:207 +#: ../../library/enum.rst:213 msgid "" ">>> some_var = Color.RED\n" ">>> some_var in Color\n" @@ -477,7 +489,7 @@ msgstr "" ">>> Color.RED.value in Color\n" "True" -#: ../../library/enum.rst:215 +#: ../../library/enum.rst:221 msgid "" "Before Python 3.12, a ``TypeError`` is raised if a non-Enum-member is used " "in a containment check." @@ -485,7 +497,7 @@ msgstr "" "在 Python 3.12 之前,如果用非列舉成員做屬於檢查 (containment check) 會引發 " "``TypeError``。" -#: ../../library/enum.rst:220 +#: ../../library/enum.rst:226 msgid "" "Returns ``['__class__', '__doc__', '__members__', '__module__']`` and the " "names of the members in *cls*::" @@ -493,7 +505,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__members__', '__module__']`` 及 *cls* 的成" "員名稱: ::" -#: ../../library/enum.rst:223 +#: ../../library/enum.rst:229 msgid "" ">>> dir(Color)\n" "['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', " @@ -505,13 +517,13 @@ msgstr "" "'__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', " "'__module__', '__name__', '__qualname__']" -#: ../../library/enum.rst:228 +#: ../../library/enum.rst:234 msgid "" "Returns the Enum member in *cls* matching *name*, or raises a :exc:" "`KeyError`::" msgstr "回傳 *cls* 中符合 *name* 的列舉成員,或引發 :exc:`KeyError`: ::" -#: ../../library/enum.rst:230 +#: ../../library/enum.rst:236 msgid "" ">>> Color['BLUE']\n" "" @@ -519,11 +531,11 @@ msgstr "" ">>> Color['BLUE']\n" "" -#: ../../library/enum.rst:235 +#: ../../library/enum.rst:241 msgid "Returns each member in *cls* in definition order::" msgstr "以定義的順序回傳在 *cls* 中的每個成員: ::" -#: ../../library/enum.rst:237 +#: ../../library/enum.rst:243 msgid "" ">>> list(Color)\n" "[, , ]" @@ -531,11 +543,11 @@ msgstr "" ">>> list(Color)\n" "[, , ]" -#: ../../library/enum.rst:242 +#: ../../library/enum.rst:248 msgid "Returns the number of member in *cls*::" msgstr "回傳 *cls* 的成員數量: ::" -#: ../../library/enum.rst:244 +#: ../../library/enum.rst:250 msgid "" ">>> len(Color)\n" "3" @@ -543,15 +555,15 @@ msgstr "" ">>> len(Color)\n" "3" -#: ../../library/enum.rst:249 +#: ../../library/enum.rst:255 msgid "Returns a mapping of every enum name to its member, including aliases" msgstr "回傳每個列舉名稱到其成員的對映,包括別名" -#: ../../library/enum.rst:253 +#: ../../library/enum.rst:259 msgid "Returns each member in *cls* in reverse definition order::" msgstr "以跟定義相反的順序回傳 *cls* 的每個成員: ::" -#: ../../library/enum.rst:255 +#: ../../library/enum.rst:261 msgid "" ">>> list(reversed(Color))\n" "[, , ]" @@ -559,15 +571,15 @@ msgstr "" ">>> list(reversed(Color))\n" "[, , ]" -#: ../../library/enum.rst:261 +#: ../../library/enum.rst:267 msgid "*Enum* is the base class for all *enum* enumerations." msgstr "*Enum* 是所有 *enum* 列舉的基礎類別。" -#: ../../library/enum.rst:265 +#: ../../library/enum.rst:271 msgid "The name used to define the ``Enum`` member::" msgstr "用來定義 ``Enum`` 成員的名稱: ::" -#: ../../library/enum.rst:267 +#: ../../library/enum.rst:273 msgid "" ">>> Color.BLUE.name\n" "'BLUE'" @@ -575,11 +587,11 @@ msgstr "" ">>> Color.BLUE.name\n" "'BLUE'" -#: ../../library/enum.rst:272 +#: ../../library/enum.rst:278 msgid "The value given to the ``Enum`` member::" msgstr "``Enum`` 成員給定的值: ::" -#: ../../library/enum.rst:274 +#: ../../library/enum.rst:280 msgid "" ">>> Color.RED.value\n" "1" @@ -587,15 +599,15 @@ msgstr "" ">>> Color.RED.value\n" "1" -#: ../../library/enum.rst:277 ../../library/enum.rst:297 +#: ../../library/enum.rst:283 ../../library/enum.rst:303 msgid "Value of the member, can be set in :meth:`~Enum.__new__`." msgstr "成員的值,可以在 :meth:`~Enum.__new__` 設定。" -#: ../../library/enum.rst:279 +#: ../../library/enum.rst:285 msgid "Enum member values" msgstr "列舉成員的值" -#: ../../library/enum.rst:281 +#: ../../library/enum.rst:287 msgid "" "Member values can be anything: :class:`int`, :class:`str`, etc. If the " "exact value is unimportant you may use :class:`auto` instances and an " @@ -605,7 +617,7 @@ msgstr "" "重要,你可以使用 :class:`auto` 實例,它會為你選擇合適的值。更多細節請參考 :" "class:`auto`。" -#: ../../library/enum.rst:286 +#: ../../library/enum.rst:292 msgid "" "While mutable/unhashable values, such as :class:`dict`, :class:`list` or a " "mutable :class:`~dataclasses.dataclass`, can be used, they will have a " @@ -616,23 +628,23 @@ msgstr "" "`dict`、:class:`list` 或可變的 :class:`~dataclasses.dataclass`,它們在建立期" "間會對效能產生相對於列舉中可變的 / 不可雜湊的值總數量的二次方影響。" -#: ../../library/enum.rst:293 +#: ../../library/enum.rst:299 msgid "Name of the member." msgstr "成員名稱。" -#: ../../library/enum.rst:301 +#: ../../library/enum.rst:307 msgid "" "No longer used, kept for backward compatibility. (class attribute, removed " "during class creation)." msgstr "已不再使用,只為了向後相容而保留(類別屬性,在類別建立時移除)" -#: ../../library/enum.rst:306 +#: ../../library/enum.rst:312 msgid "" "``_ignore_`` is only used during creation and is removed from the " "enumeration once creation is complete." msgstr "``_ignore_`` 只有在建立的時候用到,在列舉建立完成後會被移除。" -#: ../../library/enum.rst:309 +#: ../../library/enum.rst:315 msgid "" "``_ignore_`` is a list of names that will not become members, and whose " "names will also be removed from the completed enumeration. See :ref:" @@ -641,7 +653,7 @@ msgstr "" "``_ignore_`` 是一個不會變成成員的名稱串列,在列舉建立完成後其名稱會被移除。範" "例請參考 :ref:`TimePeriod `。" -#: ../../library/enum.rst:315 +#: ../../library/enum.rst:321 msgid "" "Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and any " "public methods defined on *self.__class__*::" @@ -649,7 +661,7 @@ msgstr "" "回傳 ``['__class__', '__doc__', '__module__', 'name', 'value']`` 及任何 " "*self.__class__* 上定義的公開方法: ::" -#: ../../library/enum.rst:318 +#: ../../library/enum.rst:324 msgid "" ">>> from enum import Enum\n" ">>> from datetime import date\n" @@ -691,11 +703,11 @@ msgstr "" msgid "name" msgstr "name" -#: ../../library/enum.rst:337 +#: ../../library/enum.rst:343 msgid "The name of the member being defined (e.g. 'RED')." msgstr "定義的成員名稱(例如 'RED')。" -#: ../../library/enum.rst:338 +#: ../../library/enum.rst:344 msgid "The start value for the Enum; the default is 1." msgstr "列舉的開始值,預設為 1。" @@ -703,7 +715,7 @@ msgstr "列舉的開始值,預設為 1。" msgid "count" msgstr "count" -#: ../../library/enum.rst:339 +#: ../../library/enum.rst:345 msgid "The number of members currently defined, not including this one." msgstr "已定義的成員數量,不包含目前這一個。" @@ -711,17 +723,17 @@ msgstr "已定義的成員數量,不包含目前這一個。" msgid "last_values" msgstr "last_values" -#: ../../library/enum.rst:340 +#: ../../library/enum.rst:346 msgid "A list of the previous values." msgstr "一個之前值的串列。" -#: ../../library/enum.rst:342 +#: ../../library/enum.rst:348 msgid "" "A *staticmethod* that is used to determine the next value returned by :class:" "`auto`::" msgstr "一個 *staticmethod*,用來決定 :class:`auto` 下一個要回傳的值的: ::" -#: ../../library/enum.rst:345 +#: ../../library/enum.rst:351 msgid "" ">>> from enum import auto, Enum\n" ">>> class PowersOfThree(Enum):\n" @@ -745,7 +757,7 @@ msgstr "" ">>> PowersOfThree.SECOND.value\n" "9" -#: ../../library/enum.rst:358 +#: ../../library/enum.rst:364 msgid "" "By default, does nothing. If multiple values are given in the member " "assignment, those values become separate arguments to ``__init__``; e.g." @@ -753,19 +765,19 @@ msgstr "" "預設情況下,不執行任何操作。如果在成員賦值中給出多個值,這些值將成為與 " "``__init__`` 分別的引數;例如" -#: ../../library/enum.rst:365 +#: ../../library/enum.rst:371 msgid "" "``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, " "'Mon')``" msgstr "``Weekday.__init__()`` 將被稱為 ``Weekday.__init__(self, 1, 'Mon')``" -#: ../../library/enum.rst:369 +#: ../../library/enum.rst:375 msgid "" "A *classmethod* that is used to further configure subsequent subclasses. By " "default, does nothing." msgstr "一個 *classmethod*,用來進一步設定後續的子類別,預設不做任何事。" -#: ../../library/enum.rst:374 +#: ../../library/enum.rst:380 msgid "" "A *classmethod* for looking up values not found in *cls*. By default it " "does nothing, but can be overridden to implement custom search behavior::" @@ -773,7 +785,7 @@ msgstr "" "一個 *classmethod*,用來查詢在 *cls* 裡找不到的值。預設不做任何事,但可以被覆" "寫以實作客製化的搜尋行為: ::" -#: ../../library/enum.rst:377 +#: ../../library/enum.rst:383 msgid "" ">>> from enum import auto, StrEnum\n" ">>> class Build(StrEnum):\n" @@ -809,7 +821,7 @@ msgstr "" ">>> Build('deBUG')\n" "" -#: ../../library/enum.rst:396 +#: ../../library/enum.rst:402 msgid "" "By default, doesn't exist. If specified, either in the enum class " "definition or in a mixin class (such as ``int``), all values given in the " @@ -818,12 +830,12 @@ msgstr "" "預設情況下不存在。如果有指定,無論是在列舉類別定義中還是在 mixin 類別中(例" "如 ``int``\\ ),都將傳遞成員賦值中給出的所有值;例如" -#: ../../library/enum.rst:404 +#: ../../library/enum.rst:410 msgid "" "results in the call ``int('1a', 16)`` and a value of ``26`` for the member." msgstr "會產生呼叫 ``int('1a', 16)`` 而該成員的值為 ``26``。" -#: ../../library/enum.rst:408 +#: ../../library/enum.rst:414 msgid "" "When writing a custom ``__new__``, do not use ``super().__new__`` -- call " "the appropriate ``__new__`` instead." @@ -831,7 +843,7 @@ msgstr "" "當寫自訂的 ``__new__`` 時,不要使用 ``super().__new__``,而是要呼叫適當的 " "``__new__``。" -#: ../../library/enum.rst:413 +#: ../../library/enum.rst:419 msgid "" "Returns the string used for *repr()* calls. By default, returns the *Enum* " "name, member name, and value, but can be overridden::" @@ -839,7 +851,7 @@ msgstr "" "回傳呼叫 *repr()* 時使用的字串。預設回傳 *Enum* 名稱、成員名稱及值,但可以被" "覆寫: ::" -#: ../../library/enum.rst:416 +#: ../../library/enum.rst:422 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -867,7 +879,7 @@ msgstr "" "ALTERNATE}\"\n" "(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')" -#: ../../library/enum.rst:430 +#: ../../library/enum.rst:436 msgid "" "Returns the string used for *str()* calls. By default, returns the *Enum* " "name and member name, but can be overridden::" @@ -875,7 +887,7 @@ msgstr "" "回傳呼叫 *str()* 時使用的字串。預設回傳 *Enum* 名稱及成員名稱,但可以被覆" "寫: ::" -#: ../../library/enum.rst:433 +#: ../../library/enum.rst:439 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -901,7 +913,7 @@ msgstr "" "ALTERNATE}\"\n" "(, 'ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:446 +#: ../../library/enum.rst:452 msgid "" "Returns the string used for *format()* and *f-string* calls. By default, " "returns :meth:`__str__` return value, but can be overridden::" @@ -909,7 +921,7 @@ msgstr "" "回傳呼叫 *format()* 及 *f-string* 時使用的字串。預設回傳 :meth:`__str__` 的回" "傳值,但可以被覆寫: ::" -#: ../../library/enum.rst:449 +#: ../../library/enum.rst:455 msgid "" ">>> from enum import auto, Enum\n" ">>> class OtherStyle(Enum):\n" @@ -935,21 +947,21 @@ msgstr "" "ALTERNATE}\"\n" "(, 'OtherStyle.ALTERNATE', 'ALTERNATE')" -#: ../../library/enum.rst:462 +#: ../../library/enum.rst:468 msgid "" "Using :class:`auto` with :class:`Enum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`Enum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:465 +#: ../../library/enum.rst:471 msgid "Added :ref:`enum-dataclass-support`" msgstr "新增 :ref:`enum-dataclass-support`" -#: ../../library/enum.rst:469 +#: ../../library/enum.rst:475 msgid "Adds a new name as an alias to an existing member::" msgstr "新增一個名稱作為現有成員的別名: ::" -#: ../../library/enum.rst:471 +#: ../../library/enum.rst:477 msgid "" ">>> Color.RED._add_alias_(\"ERROR\")\n" ">>> Color.ERROR\n" @@ -959,17 +971,17 @@ msgstr "" ">>> Color.ERROR\n" "" -#: ../../library/enum.rst:475 +#: ../../library/enum.rst:481 msgid "" "Raises a :exc:`NameError` if the name is already assigned to a different " "member." msgstr "如果該名稱已經被指派給不同的成員,則會引發 :exc:`NameError`。" -#: ../../library/enum.rst:481 +#: ../../library/enum.rst:487 msgid "Adds a new value as an alias to an existing member::" msgstr "新增一個值作為現有成員的別名: ::" -#: ../../library/enum.rst:483 +#: ../../library/enum.rst:489 msgid "" ">>> Color.RED._add_value_alias_(42)\n" ">>> Color(42)\n" @@ -979,13 +991,13 @@ msgstr "" ">>> Color(42)\n" "" -#: ../../library/enum.rst:487 +#: ../../library/enum.rst:493 msgid "" "Raises a :exc:`ValueError` if the value is already linked with a different " "member." msgstr "如果該值已經被連結到不同的成員,則會引發 :exc:`ValueError`。" -#: ../../library/enum.rst:494 +#: ../../library/enum.rst:500 msgid "" "*IntEnum* is the same as :class:`Enum`, but its members are also integers " "and can be used anywhere that an integer can be used. If any integer " @@ -995,13 +1007,13 @@ msgstr "" "*IntEnum* 和 :class:`Enum` 一樣,但其成員同時也是整數而可以被用在任何使用整數" "的地方。如果 *IntEnum* 成員經過任何整數運算,結果值會失去其列舉狀態。" -#: ../../library/enum.rst:515 +#: ../../library/enum.rst:521 msgid "" "Using :class:`auto` with :class:`IntEnum` results in integers of increasing " "value, starting with ``1``." msgstr ":class:`IntEnum` 使用 :class:`auto` 會產生從 ``1`` 開始遞增的整數。" -#: ../../library/enum.rst:518 +#: ../../library/enum.rst:524 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` was " @@ -1011,7 +1023,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:525 +#: ../../library/enum.rst:531 msgid "" "*StrEnum* is the same as :class:`Enum`, but its members are also strings and " "can be used in most of the same places that a string can be used. The result " @@ -1021,7 +1033,7 @@ msgstr "" "*StrEnum* 和 :class:`Enum` 一樣,但其成員同時也是字串而可以被用在幾乎所有使用" "字串的地方。*StrEnum* 成員經過任何字串操作的結果會不再是列舉的一部份。" -#: ../../library/enum.rst:546 +#: ../../library/enum.rst:552 msgid "" "There are places in the stdlib that check for an exact :class:`str` instead " "of a :class:`str` subclass (i.e. ``type(unknown) == str`` instead of " @@ -1032,13 +1044,13 @@ msgstr "" "是 ``type(unknown) == str`` 而不是 ``isinstance(unknown, str)``),在這些地方" "你需要使用 ``str(MyStrEnum.MY_MEMBER)``。" -#: ../../library/enum.rst:553 +#: ../../library/enum.rst:559 msgid "" "Using :class:`auto` with :class:`StrEnum` results in the lower-cased member " "name as the value." msgstr ":class:`StrEnum` 使用 :class:`auto` 會產生小寫的成員名稱當作值。" -#: ../../library/enum.rst:558 +#: ../../library/enum.rst:564 msgid "" ":meth:`~object.__str__` is :meth:`!str.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` is " @@ -1048,7 +1060,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!str.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 也會是 :meth:`!str.__format__`。" -#: ../../library/enum.rst:566 +#: ../../library/enum.rst:572 msgid "" "``Flag`` is the same as :class:`Enum`, but its members support the bitwise " "operators ``&`` (*AND*), ``|`` (*OR*), ``^`` (*XOR*), and ``~`` (*INVERT*); " @@ -1058,11 +1070,11 @@ msgstr "" "(*OR*)、``^`` (*XOR*) 和 ``~`` (*INVERT*);這些操作的結果是列舉的成員(的別" "名)。" -#: ../../library/enum.rst:572 +#: ../../library/enum.rst:578 msgid "Returns *True* if value is in self::" msgstr "如果 value 在 self 裡則回傳 *True*: ::" -#: ../../library/enum.rst:574 +#: ../../library/enum.rst:580 msgid "" ">>> from enum import Flag, auto\n" ">>> class Color(Flag):\n" @@ -1098,11 +1110,11 @@ msgstr "" ">>> white in purple\n" "False" -#: ../../library/enum.rst:593 +#: ../../library/enum.rst:599 msgid "Returns all contained non-alias members::" msgstr "回傳所有包含的非別名成員: ::" -#: ../../library/enum.rst:595 +#: ../../library/enum.rst:601 msgid "" ">>> list(Color.RED)\n" "[]\n" @@ -1114,11 +1126,11 @@ msgstr "" ">>> list(purple)\n" "[, ]" -#: ../../library/enum.rst:604 +#: ../../library/enum.rst:610 msgid "Returns number of members in flag::" msgstr "回傳旗標裡的成員數量: ::" -#: ../../library/enum.rst:606 +#: ../../library/enum.rst:612 msgid "" ">>> len(Color.GREEN)\n" "1\n" @@ -1130,11 +1142,11 @@ msgstr "" ">>> len(white)\n" "3" -#: ../../library/enum.rst:615 +#: ../../library/enum.rst:621 msgid "Returns *True* if any members in flag, *False* otherwise::" msgstr "如果成員在旗標裡則回傳 *True*,否則回傳 *False*: ::" -#: ../../library/enum.rst:617 +#: ../../library/enum.rst:623 msgid "" ">>> bool(Color.GREEN)\n" "True\n" @@ -1152,11 +1164,11 @@ msgstr "" ">>> bool(black)\n" "False" -#: ../../library/enum.rst:627 +#: ../../library/enum.rst:633 msgid "Returns current flag binary or'ed with other::" msgstr "回傳和 other 做 OR 過後的二進位旗標: ::" -#: ../../library/enum.rst:629 +#: ../../library/enum.rst:635 msgid "" ">>> Color.RED | Color.GREEN\n" "" @@ -1164,11 +1176,11 @@ msgstr "" ">>> Color.RED | Color.GREEN\n" "" -#: ../../library/enum.rst:634 +#: ../../library/enum.rst:640 msgid "Returns current flag binary and'ed with other::" msgstr "回傳和 other 做 AND 過後的二進位旗標: ::" -#: ../../library/enum.rst:636 +#: ../../library/enum.rst:642 msgid "" ">>> purple & white\n" "\n" @@ -1180,11 +1192,11 @@ msgstr "" ">>> purple & Color.GREEN\n" "" -#: ../../library/enum.rst:643 +#: ../../library/enum.rst:649 msgid "Returns current flag binary xor'ed with other::" msgstr "回傳和 other 做 XOR 過後的二進位旗標: ::" -#: ../../library/enum.rst:645 +#: ../../library/enum.rst:651 msgid "" ">>> purple ^ white\n" "\n" @@ -1196,11 +1208,11 @@ msgstr "" ">>> purple ^ Color.GREEN\n" "" -#: ../../library/enum.rst:652 +#: ../../library/enum.rst:658 msgid "Returns all the flags in *type(self)* that are not in *self*::" msgstr "回傳所有在 *type(self)* 但不在 *self* 裡的旗標: ::" -#: ../../library/enum.rst:654 +#: ../../library/enum.rst:660 msgid "" ">>> ~white\n" "\n" @@ -1216,7 +1228,7 @@ msgstr "" ">>> ~Color.RED\n" "" -#: ../../library/enum.rst:663 +#: ../../library/enum.rst:669 msgid "" "Function used to format any remaining unnamed numeric values. Default is " "the value's repr; common choices are :func:`hex` and :func:`oct`." @@ -1224,17 +1236,17 @@ msgstr "" "用來格式化任何剩下未命名數值的函式。預設是值的 repr,常見選擇是 :func:`hex` " "和 :func:`oct`。" -#: ../../library/enum.rst:668 +#: ../../library/enum.rst:674 msgid "" "Using :class:`auto` with :class:`Flag` results in integers that are powers " "of two, starting with ``1``." msgstr ":class:`Flag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:671 +#: ../../library/enum.rst:677 msgid "The *repr()* of zero-valued flags has changed. It is now:" msgstr "值為 0 的旗標的 *repr()* 已改變。現在是:" -#: ../../library/enum.rst:679 +#: ../../library/enum.rst:685 msgid "" "``IntFlag`` is the same as :class:`Flag`, but its members are also integers " "and can be used anywhere that an integer can be used." @@ -1242,13 +1254,13 @@ msgstr "" "``IntFlag`` 和 :class:`Flag` 一樣,但其成員同時也是整數而可以被用在任何使用整" "數的地方。" -#: ../../library/enum.rst:693 +#: ../../library/enum.rst:699 msgid "" "If any integer operation is performed with an *IntFlag* member, the result " "is not an *IntFlag*::" msgstr "如果 *IntFlag* 成員經過任何整數運算,其結果不是 *IntFlag*: ::" -#: ../../library/enum.rst:696 +#: ../../library/enum.rst:702 msgid "" ">>> Color.RED + 2\n" "3" @@ -1256,25 +1268,25 @@ msgstr "" ">>> Color.RED + 2\n" "3" -#: ../../library/enum.rst:699 +#: ../../library/enum.rst:705 msgid "If a :class:`Flag` operation is performed with an *IntFlag* member and:" msgstr "如果 *IntFlag* 成員經過 :class:`Flag` 操作且:" -#: ../../library/enum.rst:701 +#: ../../library/enum.rst:707 msgid "the result is a valid *IntFlag*: an *IntFlag* is returned" msgstr "結果是合法的 *IntFlag*:回傳 *IntFlag*" -#: ../../library/enum.rst:702 +#: ../../library/enum.rst:708 msgid "" "the result is not a valid *IntFlag*: the result depends on the :class:" "`FlagBoundary` setting" msgstr "結果不是合法的 *IntFlag*:結果會根據 :class:`FlagBoundary` 的設定" -#: ../../library/enum.rst:704 +#: ../../library/enum.rst:710 msgid "The :func:`repr` of unnamed zero-valued flags has changed. It is now::" msgstr "未命名且值為 0 的旗標的 :func:`repr` 已改變。現在是: ::" -#: ../../library/enum.rst:706 +#: ../../library/enum.rst:712 msgid "" ">>> Color(0)\n" "" @@ -1282,14 +1294,14 @@ msgstr "" ">>> Color(0)\n" "" -#: ../../library/enum.rst:711 +#: ../../library/enum.rst:717 msgid "" "Using :class:`auto` with :class:`IntFlag` results in integers that are " "powers of two, starting with ``1``." msgstr "" ":class:`IntFlag` 使用 :class:`auto` 會產生從 ``1`` 開始 2 的次方的整數。" -#: ../../library/enum.rst:716 +#: ../../library/enum.rst:722 msgid "" ":meth:`~object.__str__` is now :meth:`!int.__str__` to better support the " "*replacement of existing constants* use-case. :meth:`~object.__format__` " @@ -1299,7 +1311,7 @@ msgstr "" "境,:meth:`~object.__str__` 現在會是 :meth:`!int.__str__`。為了同樣的理由,:" "meth:`~object.__format__` 已經是 :meth:`!int.__format__`。" -#: ../../library/enum.rst:720 +#: ../../library/enum.rst:726 msgid "" "Inversion of an :class:`!IntFlag` now returns a positive value that is the " "union of all flags not in the given flag, rather than a negative value. This " @@ -1308,7 +1320,7 @@ msgstr "" ":class:`!IntFlag` 的反轉 (inversion) 現在會回傳正值,該值是不在給定旗標的所有" "旗標聯集,而不是一個負值。這符合現有 :class:`Flag` 的行為。" -#: ../../library/enum.rst:726 +#: ../../library/enum.rst:732 msgid "" ":class:`!ReprEnum` uses the :meth:`repr() ` of :class:`Enum`, " "but the :class:`str() ` of the mixed-in data type:" @@ -1316,15 +1328,15 @@ msgstr "" ":class:`!ReprEnum` 使用 :class:`Enum` 的 :meth:`repr() `,但使" "用混合資料型別的 :class:`str() `:" -#: ../../library/enum.rst:729 +#: ../../library/enum.rst:735 msgid ":meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`" msgstr "對 :class:`IntEnum` 和 :class:`IntFlag` 是 :meth:`!int.__str__`" -#: ../../library/enum.rst:730 +#: ../../library/enum.rst:736 msgid ":meth:`!str.__str__` for :class:`StrEnum`" msgstr "對 :class:`StrEnum` 是 :meth:`!str.__str__`" -#: ../../library/enum.rst:732 +#: ../../library/enum.rst:738 msgid "" "Inherit from :class:`!ReprEnum` to keep the :class:`str() ` / :func:" "`format` of the mixed-in data type instead of using the :class:`Enum`-" @@ -1333,7 +1345,7 @@ msgstr "" "繼承 :class:`!ReprEnum` 來保留混合資料型別的 :class:`str() ` / :func:" "`format`,而不是使用 :class:`Enum` 預設的 :meth:`str() `。" -#: ../../library/enum.rst:741 +#: ../../library/enum.rst:747 msgid "" "*EnumCheck* contains the options used by the :func:`verify` decorator to " "ensure various constraints; failed constraints result in a :exc:`ValueError`." @@ -1341,11 +1353,11 @@ msgstr "" "*EnumCheck* 包含 :func:`verify` 裝飾器使用的選項,以確保多樣的限制,不符合限" "制會產生 :exc:`ValueError`。" -#: ../../library/enum.rst:746 +#: ../../library/enum.rst:752 msgid "Ensure that each value has only one name::" msgstr "確保每個值只有一個名稱: ::" -#: ../../library/enum.rst:748 +#: ../../library/enum.rst:754 msgid "" ">>> from enum import Enum, verify, UNIQUE\n" ">>> @verify(UNIQUE)\n" @@ -1369,13 +1381,13 @@ msgstr "" "...\n" "ValueError: aliases found in : CRIMSON -> RED" -#: ../../library/enum.rst:762 +#: ../../library/enum.rst:768 msgid "" "Ensure that there are no missing values between the lowest-valued member and " "the highest-valued member::" msgstr "確保在最小值成員跟最大值成員間沒有缺少值: ::" -#: ../../library/enum.rst:765 +#: ../../library/enum.rst:771 msgid "" ">>> from enum import Enum, verify, CONTINUOUS\n" ">>> @verify(CONTINUOUS)\n" @@ -1397,7 +1409,7 @@ msgstr "" "...\n" "ValueError: invalid enum 'Color': missing values 3, 4" -#: ../../library/enum.rst:777 +#: ../../library/enum.rst:783 msgid "" "Ensure that any flag groups/masks contain only named flags -- useful when " "values are specified instead of being generated by :func:`auto`::" @@ -1405,7 +1417,7 @@ msgstr "" "確保任何旗標群組 / 遮罩只包含命名旗標 -- 當值是用指定而不是透過 :func:`auto` " "產生時是很實用的: ::" -#: ../../library/enum.rst:780 +#: ../../library/enum.rst:786 msgid "" ">>> from enum import Flag, verify, NAMED_FLAGS\n" ">>> @verify(NAMED_FLAGS)\n" @@ -1433,24 +1445,24 @@ msgstr "" "ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing " "combined values of 0x18 [use enum.show_flag_values(value) for details]" -#: ../../library/enum.rst:794 +#: ../../library/enum.rst:800 msgid "" "CONTINUOUS and NAMED_FLAGS are designed to work with integer-valued members." msgstr "CONTINUOUS 和 NAMED_FLAGS 是設計用來運作在整數值的成員上。" -#: ../../library/enum.rst:800 +#: ../../library/enum.rst:806 msgid "" "``FlagBoundary`` controls how out-of-range values are handled in :class:" "`Flag` and its subclasses." msgstr "``FlagBoundary`` 控制在 :class:`Flag` 及其子類別中如何處理範圍外的值。" -#: ../../library/enum.rst:805 +#: ../../library/enum.rst:811 msgid "" "Out-of-range values cause a :exc:`ValueError` to be raised. This is the " "default for :class:`Flag`::" msgstr "範圍外的值會引發 :exc:`ValueError`。這是 :class:`Flag` 的預設行為: ::" -#: ../../library/enum.rst:808 +#: ../../library/enum.rst:814 msgid "" ">>> from enum import Flag, STRICT, auto\n" ">>> class StrictFlag(Flag, boundary=STRICT):\n" @@ -1478,13 +1490,13 @@ msgstr "" " given 0b0 10100\n" " allowed 0b0 00111" -#: ../../library/enum.rst:823 +#: ../../library/enum.rst:829 msgid "" "Out-of-range values have invalid values removed, leaving a valid :class:" "`Flag` value::" msgstr "會移除範圍外的值中的非法值,留下合法的 :class:`Flag` 值: ::" -#: ../../library/enum.rst:826 +#: ../../library/enum.rst:832 msgid "" ">>> from enum import Flag, CONFORM, auto\n" ">>> class ConformFlag(Flag, boundary=CONFORM):\n" @@ -1504,13 +1516,13 @@ msgstr "" ">>> ConformFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:837 +#: ../../library/enum.rst:843 msgid "" "Out-of-range values lose their :class:`Flag` membership and revert to :class:" "`int`." msgstr "範圍外的值會失去它們的 :class:`Flag` 成員資格且恢復成 :class:`int`。" -#: ../../library/enum.rst:850 +#: ../../library/enum.rst:856 msgid "" "Out-of-range values are kept, and the :class:`Flag` membership is kept. This " "is the default for :class:`IntFlag`::" @@ -1518,7 +1530,7 @@ msgstr "" "範圍外的值會被保留,:class:`Flag` 成員資格也會被保留。這是 :class:`IntFlag` " "的預設行為: ::" -#: ../../library/enum.rst:853 +#: ../../library/enum.rst:859 msgid "" ">>> from enum import Flag, KEEP, auto\n" ">>> class KeepFlag(Flag, boundary=KEEP):\n" @@ -1538,7 +1550,7 @@ msgstr "" ">>> KeepFlag(2**2 + 2**4)\n" "" -#: ../../library/enum.rst:866 +#: ../../library/enum.rst:872 msgid "" "*EnumDict* is a subclass of :class:`dict` that is used as the namespace for " "defining enum classes (see :ref:`prepare`). It is exposed to allow " @@ -1552,7 +1564,7 @@ msgstr "" "如讓每個成員有多個值。它應該在被呼叫時帶上正在建立的列舉類別名稱,否則私有名" "稱和內部類別將無法被正確處理。" -#: ../../library/enum.rst:873 +#: ../../library/enum.rst:879 msgid "" "Note that only the :class:`~collections.abc.MutableMapping` interface (:meth:" "`~object.__setitem__` and :meth:`~dict.update`) is overridden. It may be " @@ -1563,15 +1575,15 @@ msgstr "" "__setitem__` 和 :meth:`~dict.update`)被覆寫。可能可以使用其他 :class:`!" "dict` 操作來繞過檢查,例如 :meth:`|= `。" -#: ../../library/enum.rst:880 +#: ../../library/enum.rst:886 msgid "A list of member names." msgstr "一個成員名稱的串列。" -#: ../../library/enum.rst:887 +#: ../../library/enum.rst:893 msgid "Supported ``__dunder__`` names" msgstr "支援的 ``__dunder__`` 名稱" -#: ../../library/enum.rst:889 +#: ../../library/enum.rst:895 msgid "" ":attr:`~EnumType.__members__` is a read-only ordered mapping of " "``member_name``:``member`` items. It is only available on the class." @@ -1579,7 +1591,7 @@ msgstr "" ":attr:`~EnumType.__members__` 是一個唯讀有序的\\ ``成員名稱``:``成員``\\ 項" "目的對映。只有在類別上可用。" -#: ../../library/enum.rst:892 +#: ../../library/enum.rst:898 msgid "" ":meth:`~Enum.__new__`, if specified, must create and return the enum " "members; it is also a very good idea to set the member's :attr:`!_value_` " @@ -1589,26 +1601,26 @@ msgstr "" "的 :attr:`!_value_` 也是一個很好的主意。一旦所有成員都建立之後就不會再被用" "到。" -#: ../../library/enum.rst:898 +#: ../../library/enum.rst:904 msgid "Supported ``_sunder_`` names" msgstr "支援的 ``_sunder_`` 名稱" -#: ../../library/enum.rst:900 +#: ../../library/enum.rst:906 msgid ":attr:`~Enum._name_` -- name of the member" msgstr ":attr:`~Enum._name_` -- 成員名稱" -#: ../../library/enum.rst:901 +#: ../../library/enum.rst:907 msgid ":attr:`~Enum._value_` -- value of the member; can be set in ``__new__``" msgstr ":attr:`~Enum._value_` -- 成員的值;可以在 ``__new__`` 設定" -#: ../../library/enum.rst:902 +#: ../../library/enum.rst:908 msgid "" ":meth:`~Enum._missing_` -- a lookup function used when a value is not found; " "may be overridden" msgstr "" ":meth:`~Enum._missing_` -- 當值沒有被找到時會使用的查詢函式;可以被覆寫" -#: ../../library/enum.rst:904 +#: ../../library/enum.rst:910 msgid "" ":attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a :" "class:`str`, that will not be transformed into members, and will be removed " @@ -1617,7 +1629,7 @@ msgstr "" ":attr:`~Enum._ignore_` -- 一個名稱的串列,可以是 :class:`list` 或 :class:" "`str`,它不會被轉換成成員,且在最後的類別上會被移除" -#: ../../library/enum.rst:907 +#: ../../library/enum.rst:913 msgid "" ":attr:`~Enum._order_` -- no longer used, kept for backward compatibility " "(class attribute, removed during class creation)" @@ -1625,40 +1637,40 @@ msgstr "" ":attr:`~Enum._order_` -- 不再被使用,僅為了向後相容而保留(類別屬性,在類別建" "立時移除)" -#: ../../library/enum.rst:909 +#: ../../library/enum.rst:915 msgid "" ":meth:`~Enum._generate_next_value_` -- used to get an appropriate value for " "an enum member; may be overridden" msgstr "" ":meth:`~Enum._generate_next_value_` -- 用來為列舉成員取得合適的值;可以被覆寫" -#: ../../library/enum.rst:914 +#: ../../library/enum.rst:920 msgid "" "For standard :class:`Enum` classes the next value chosen is the highest " "value seen incremented by one." msgstr "" "對標準的 :class:`Enum` 類別來說,下一個被選擇的值是所看過的最大值加一。" -#: ../../library/enum.rst:917 +#: ../../library/enum.rst:923 msgid "" "For :class:`Flag` classes the next value chosen will be the next highest " "power-of-two." msgstr "" "對 :class:`Flag` 類別來說,下一個被選擇的值是下一個最大的 2 的次方的數字。" -#: ../../library/enum.rst:920 +#: ../../library/enum.rst:926 msgid "" ":meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing " "member." msgstr ":meth:`~Enum._add_alias_` -- 新增一個名稱作為現有成員的別名。" -#: ../../library/enum.rst:922 +#: ../../library/enum.rst:928 msgid "" ":meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an " "existing member." msgstr ":meth:`~Enum._add_value_alias_` -- 新增一個值作為現有成員的別名。" -#: ../../library/enum.rst:925 +#: ../../library/enum.rst:931 msgid "" "While ``_sunder_`` names are generally reserved for the further development " "of the :class:`Enum` class and can not be used, some are explicitly allowed:" @@ -1666,30 +1678,30 @@ msgstr "" "雖然 ``_sunder_`` 名稱通常保留用於 :class:`Enum` 類別的進一步開發而不能被使" "用,但有些是明確允許的:" -#: ../../library/enum.rst:928 +#: ../../library/enum.rst:934 msgid "" "``_repr_*`` (e.g. ``_repr_html_``), as used in `IPython's rich display`_" msgstr "" "``_repr_*``\\ (例如 ``_repr_html_``),例如用於 `IPython 的豐富顯示 " "`_" -#: ../../library/enum.rst:930 +#: ../../library/enum.rst:936 msgid "``_missing_``, ``_order_``, ``_generate_next_value_``" msgstr "``_missing_``、``_order_``、``_generate_next_value_``" -#: ../../library/enum.rst:931 +#: ../../library/enum.rst:937 msgid "``_ignore_``" msgstr "``_ignore_``" -#: ../../library/enum.rst:932 +#: ../../library/enum.rst:938 msgid "``_add_alias_``, ``_add_value_alias_``, ``_repr_*``" msgstr "``_add_alias_``、``_add_value_alias_``、``_repr_*``" -#: ../../library/enum.rst:938 +#: ../../library/enum.rst:944 msgid "Utilities and Decorators" msgstr "通用項目與裝飾器" -#: ../../library/enum.rst:942 +#: ../../library/enum.rst:948 msgid "" "*auto* can be used in place of a value. If used, the *Enum* machinery will " "call an :class:`Enum`'s :meth:`~Enum._generate_next_value_` to get an " @@ -1705,17 +1717,18 @@ msgstr "" "`IntFlag` 來說,是第一個比最大值還大的 2 的次方的數字;對 :class:`StrEnum` 來" "說,是成員名稱的小寫版本。如果混用 *auto()* 和手動指定值的話要特別注意。" -#: ../../library/enum.rst:950 +#: ../../library/enum.rst:956 msgid "" "*auto* instances are only resolved when at the top level of an assignment, " "either by itself or as part of a tuple:" -msgstr "*auto* 實例只有在最上層的賦值時才會被解析,不論是獨自一個或作為元組的一部分:" +msgstr "" +"*auto* 實例只有在最上層的賦值時才會被解析,不論是獨自一個或作為元組的一部分:" -#: ../../library/enum.rst:953 +#: ../../library/enum.rst:959 msgid "``FIRST = auto()`` will work (auto() is replaced with ``1``);" msgstr "``FIRST = auto()`` 可以運作(auto() 會被取代成 ``1``)" -#: ../../library/enum.rst:954 +#: ../../library/enum.rst:960 msgid "" "``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` " "is used to create the ``SECOND`` enum member;" @@ -1723,27 +1736,27 @@ msgstr "" "``SECOND = auto(), -2`` 可以運作(auto 會被取代成 ``2``, 因此 ``2, -2`` 會被" "用來建立列舉成員 ``SECOND``;" -#: ../../library/enum.rst:956 +#: ../../library/enum.rst:962 msgid "" "``THREE = [auto(), -3]`` will *not* work (``[, -3]`` is used " "to create the ``THREE`` enum member)" msgstr "" -"``THREE = [auto(), -3]`` *無法*\\ 運作(``[, -3]`` 會被用來建立列" -"舉成員 ``THREE``)" +"``THREE = [auto(), -3]`` *無法*\\ 運作(``[, -3]`` 會被用來建" +"立列舉成員 ``THREE``)" -#: ../../library/enum.rst:961 +#: ../../library/enum.rst:967 msgid "" "In prior versions, ``auto()`` had to be the only thing on the assignment " "line to work properly." msgstr "在之前的版本中,``auto()`` 必須是賦值行裡的唯一內容才能運作正確。" -#: ../../library/enum.rst:964 +#: ../../library/enum.rst:970 msgid "" "``_generate_next_value_`` can be overridden to customize the values used by " "*auto*." msgstr "可以覆寫 ``_generate_next_value_`` 來客製 *auto* 使用的值。" -#: ../../library/enum.rst:967 +#: ../../library/enum.rst:973 msgid "" "in 3.13 the default ``_generate_next_value_`` will always return the highest " "member value incremented by 1, and will fail if any member is an " @@ -1752,7 +1765,7 @@ msgstr "" "在 3.13 預設 ``_generate_next_value_`` 總是回傳最大的成員值加一,如果任何成員" "是不相容的型別就會失敗。" -#: ../../library/enum.rst:973 +#: ../../library/enum.rst:979 msgid "" "A decorator similar to the built-in *property*, but specifically for " "enumerations. It allows member attributes to have the same names as members " @@ -1761,7 +1774,7 @@ msgstr "" "和內建的 *property* 相似的裝飾器,但只專門針對列舉。它允許成員屬性和成員本身" "有相同名稱。" -#: ../../library/enum.rst:977 +#: ../../library/enum.rst:983 msgid "" "the *property* and the member must be defined in separate classes; for " "example, the *value* and *name* attributes are defined in the *Enum* class, " @@ -1771,7 +1784,7 @@ msgstr "" "*屬性*\\ 和成員必須定義在分開的類別裡;例如 *value* 和 *name* 屬性定義在 " "*Enum* 類別而 *Enum* 子類別可以定義成員名稱為 ``value`` 和 ``name``。" -#: ../../library/enum.rst:986 +#: ../../library/enum.rst:992 msgid "" "A :keyword:`class` decorator specifically for enumerations. It searches an " "enumeration's :attr:`~EnumType.__members__`, gathering any aliases it finds; " @@ -1781,7 +1794,7 @@ msgstr "" "__members__`,蒐集任何它找到的別名;如果有找到任何別名則引發 :exc:" "`ValueError` 並附上細節: ::" -#: ../../library/enum.rst:990 +#: ../../library/enum.rst:996 msgid "" ">>> from enum import Enum, unique\n" ">>> @unique\n" @@ -1807,7 +1820,7 @@ msgstr "" "...\n" "ValueError: duplicate values found in : FOUR -> THREE" -#: ../../library/enum.rst:1004 +#: ../../library/enum.rst:1010 msgid "" "A :keyword:`class` decorator specifically for enumerations. Members from :" "class:`EnumCheck` are used to specify which constraints should be checked on " @@ -1816,15 +1829,15 @@ msgstr "" "專門針對列舉的 :keyword:`class` 裝飾器。使用 :class:`EnumCheck` 裡的成員來指" "定在裝飾的列舉上應該檢查什麼限制。" -#: ../../library/enum.rst:1012 +#: ../../library/enum.rst:1018 msgid "A decorator for use in enums: its target will become a member." msgstr "列舉所使用的裝飾器:其目標會變成成員。" -#: ../../library/enum.rst:1018 +#: ../../library/enum.rst:1024 msgid "A decorator for use in enums: its target will not become a member." msgstr "列舉所使用的裝飾器:其目標不會變成成員。" -#: ../../library/enum.rst:1024 +#: ../../library/enum.rst:1030 msgid "" "A decorator to change the :class:`str() ` and :func:`repr` of an enum " "to show its members as belonging to the module instead of its class. Should " @@ -1835,19 +1848,19 @@ msgstr "" "組而不是其類別。應該只有當列舉成員被匯出到模組的全域命名空間才使用(範例請參" "考 :class:`re.RegexFlag`)。" -#: ../../library/enum.rst:1034 +#: ../../library/enum.rst:1040 msgid "Return a list of all power-of-two integers contained in a flag *value*." msgstr "回傳在旗標\\ *值*\\ 中包含的所有 2 的次方的整數串列。" -#: ../../library/enum.rst:1041 +#: ../../library/enum.rst:1061 msgid "Notes" msgstr "備註" -#: ../../library/enum.rst:1043 +#: ../../library/enum.rst:1063 msgid ":class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`" msgstr ":class:`IntEnum`、:class:`StrEnum` 及 :class:`IntFlag`" -#: ../../library/enum.rst:1045 +#: ../../library/enum.rst:1065 msgid "" "These three enum types are designed to be drop-in replacements for existing " "integer- and string-based values; as such, they have extra limitations:" @@ -1855,17 +1868,17 @@ msgstr "" "這三種列舉型別是設計來直接取代現有以整數及字串為基底的值;因此它們有額外的限" "制:" -#: ../../library/enum.rst:1048 +#: ../../library/enum.rst:1068 msgid "``__str__`` uses the value and not the name of the enum member" msgstr "``__str__`` 使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1050 +#: ../../library/enum.rst:1070 msgid "" "``__format__``, because it uses ``__str__``, will also use the value of the " "enum member instead of its name" msgstr "``__format__`` 因為使用 ``__str__``,也會使用值而不是列舉成員的名稱" -#: ../../library/enum.rst:1053 +#: ../../library/enum.rst:1073 msgid "" "If you do not need/want those limitations, you can either create your own " "base class by mixing in the ``int`` or ``str`` type yourself::" @@ -1873,7 +1886,7 @@ msgstr "" "如果你不需要或不想要這些限制,你可以透過混合 ``int`` 或 ``str`` 型別來建立自" "己的基礎類別: ::" -#: ../../library/enum.rst:1056 +#: ../../library/enum.rst:1076 msgid "" ">>> from enum import Enum\n" ">>> class MyIntEnum(int, Enum):\n" @@ -1883,11 +1896,11 @@ msgstr "" ">>> class MyIntEnum(int, Enum):\n" "... pass" -#: ../../library/enum.rst:1060 +#: ../../library/enum.rst:1080 msgid "or you can reassign the appropriate :meth:`str`, etc., in your enum::" msgstr "或者你也可以在你的列舉重新給定合適的 :meth:`str`: ::" -#: ../../library/enum.rst:1062 +#: ../../library/enum.rst:1082 msgid "" ">>> from enum import Enum, IntEnum\n" ">>> class MyIntEnum(IntEnum):\n" diff --git a/library/functions.po b/library/functions.po index d443021cdc3..306505446d1 100644 --- a/library/functions.po +++ b/library/functions.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-12-15 00:16+0000\n" +"POT-Creation-Date: 2026-01-12 12:22+0000\n" "PO-Revision-Date: 2024-05-06 17:06+0800\n" "Last-Translator: KNChiu \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -514,12 +514,17 @@ msgid "" "ways." msgstr "如果不一定需要 \"0b\" 前綴,還可以使用如下的方法。" -#: ../../library/functions.rst:141 ../../library/functions.rst:948 -#: ../../library/functions.rst:1332 +#: ../../library/functions.rst:141 +msgid "" +"See also :func:`enum.bin` to represent negative values as twos-complement." +msgstr "" + +#: ../../library/functions.rst:143 ../../library/functions.rst:950 +#: ../../library/functions.rst:1334 msgid "See also :func:`format` for more information." msgstr "可參考 :func:`format` 取得更多資訊。" -#: ../../library/functions.rst:146 +#: ../../library/functions.rst:148 msgid "" "Return a Boolean value, i.e. one of ``True`` or ``False``. The argument is " "converted using the standard :ref:`truth testing procedure `. If the " @@ -534,11 +539,11 @@ msgstr "" "(參見 :ref:`typesnumeric`),其他 class 不能繼承自它。它只有 ``False`` 和 " "``True`` 兩個實例(參見 :ref:`typebool`)。" -#: ../../library/functions.rst:156 ../../library/functions.rst:813 +#: ../../library/functions.rst:158 ../../library/functions.rst:815 msgid "The parameter is now positional-only." msgstr "現在為僅限位置參數。" -#: ../../library/functions.rst:161 +#: ../../library/functions.rst:163 msgid "" "This function drops you into the debugger at the call site. Specifically, " "it calls :func:`sys.breakpointhook`, passing ``args`` and ``kws`` straight " @@ -558,7 +563,7 @@ msgstr "" "`breakpoint` 將自動呼叫該函式,讓你進入所選擇的除錯器。如果無法存取 :func:" "`sys.breakpointhook` 這個函式,則此函式將引發 :exc:`RuntimeError`。" -#: ../../library/functions.rst:173 +#: ../../library/functions.rst:175 msgid "" "By default, the behavior of :func:`breakpoint` can be changed with the :" "envvar:`PYTHONBREAKPOINT` environment variable. See :func:`sys." @@ -567,13 +572,13 @@ msgstr "" "預設情況下,:func:`breakpoint` 的行為可以透過 :envvar:`PYTHONBREAKPOINT` 環境" "變數來更改。有關使用詳情,請參考 :func:`sys.breakpointhook`。" -#: ../../library/functions.rst:177 +#: ../../library/functions.rst:179 msgid "" "Note that this is not guaranteed if :func:`sys.breakpointhook` has been " "replaced." msgstr "請注意,如果 :func:`sys.breakpointhook` 被替換了,則無法保證此功能。" -#: ../../library/functions.rst:180 +#: ../../library/functions.rst:182 msgid "" "Raises an :ref:`auditing event ` ``builtins.breakpoint`` with " "argument ``breakpointhook``." @@ -581,7 +586,7 @@ msgstr "" "引發一個附帶引數 ``breakpointhook`` 的\\ :ref:`稽核事件 ` " "``builtins.breakpoint``。" -#: ../../library/functions.rst:189 +#: ../../library/functions.rst:191 msgid "" "Return a new array of bytes. The :class:`bytearray` class is a mutable " "sequence of integers in the range 0 <= x < 256. It has most of the usual " @@ -593,13 +598,13 @@ msgstr "" "`typesseq-mutable` 中所述),同時也有 :class:`bytes` 型別大部分的 method,參" "見 :ref:`bytes-methods`。" -#: ../../library/functions.rst:194 +#: ../../library/functions.rst:196 msgid "" "The optional *source* parameter can be used to initialize the array in a few " "different ways:" msgstr "選擇性參數 *source* 可以被用來以不同的方式初始化陣列:" -#: ../../library/functions.rst:197 +#: ../../library/functions.rst:199 msgid "" "If it is a *string*, you must also give the *encoding* (and optionally, " "*errors*) parameters; :func:`bytearray` then converts the string to bytes " @@ -609,14 +614,14 @@ msgstr "" "*errors* );:func:`bytearray` 會使用 :meth:`str.encode` method 來將 string " "轉變成 bytes。" -#: ../../library/functions.rst:201 +#: ../../library/functions.rst:203 msgid "" "If it is an *integer*, the array will have that size and will be initialized " "with null bytes." msgstr "" "如果是一個 *integer*,陣列則會有該數值的長度,並以 null bytes 來當作初始值。" -#: ../../library/functions.rst:204 +#: ../../library/functions.rst:206 msgid "" "If it is an object conforming to the :ref:`buffer interface " "`, a read-only buffer of the object will be used to " @@ -625,7 +630,7 @@ msgstr "" "如果是一個符合 :ref:`buffer 介面 `\\ 的物件,該物件的唯讀 " "buffer 會被用來初始化 bytes 陣列。" -#: ../../library/functions.rst:207 +#: ../../library/functions.rst:209 msgid "" "If it is an *iterable*, it must be an iterable of integers in the range ``0 " "<= x < 256``, which are used as the initial contents of the array." @@ -633,15 +638,15 @@ msgstr "" "如果是一個 *iterable*,它的元素必須是範圍為 ``0 <= x < 256`` 的整數,並且會被" "用作陣列的初始值。" -#: ../../library/functions.rst:210 +#: ../../library/functions.rst:212 msgid "Without an argument, an array of size 0 is created." msgstr "如果沒有引數,則建立長度為 0 的陣列。" -#: ../../library/functions.rst:212 +#: ../../library/functions.rst:214 msgid "See also :ref:`binaryseq` and :ref:`typebytearray`." msgstr "可參考 :ref:`binaryseq` 和 :ref:`typebytearray`。" -#: ../../library/functions.rst:220 +#: ../../library/functions.rst:222 msgid "" "Return a new \"bytes\" object which is an immutable sequence of integers in " "the range ``0 <= x < 256``. :class:`bytes` is an immutable version of :" @@ -652,20 +657,20 @@ msgstr "" "變序列。:class:`bytes` 是 :class:`bytearray` 的不可變版本 — 它的同樣具備不改" "變物件的 method,也有相同的索引和切片操作。" -#: ../../library/functions.rst:225 +#: ../../library/functions.rst:227 msgid "" "Accordingly, constructor arguments are interpreted as for :func:`bytearray`." msgstr "因此,建構函式的引數和 :func:`bytearray` 相同。" -#: ../../library/functions.rst:227 +#: ../../library/functions.rst:229 msgid "Bytes objects can also be created with literals, see :ref:`strings`." msgstr "Bytes 物件還可以用文字建立,參見 :ref:`strings`。" -#: ../../library/functions.rst:229 +#: ../../library/functions.rst:231 msgid "See also :ref:`binaryseq`, :ref:`typebytes`, and :ref:`bytes-methods`." msgstr "可參考 :ref:`binaryseq`、:ref:`typebytes` 和 :ref:`bytes-methods`。" -#: ../../library/functions.rst:234 +#: ../../library/functions.rst:236 msgid "" "Return :const:`True` if the *object* argument appears callable, :const:" "`False` if not. If this returns ``True``, it is still possible that a call " @@ -678,13 +683,13 @@ msgstr "" "會失敗。注意 class 是可呼叫的(呼叫 class 會回傳一個新的實例);如果實例的 " "class 有定義 :meth:`~object.__call__` method,則它是可呼叫的。" -#: ../../library/functions.rst:240 +#: ../../library/functions.rst:242 msgid "" "This function was first removed in Python 3.0 and then brought back in " "Python 3.2." msgstr "這個函式一開始在 Python 3.0 被移除,但在 Python 3.2 又被重新加入。" -#: ../../library/functions.rst:247 +#: ../../library/functions.rst:249 msgid "" "Return the string representing a character with the specified Unicode code " "point. For example, ``chr(97)`` returns the string ``'a'``, while " @@ -693,7 +698,7 @@ msgstr "" "回傳代表有特定 Unicode 編碼位置字元的字串。例如,``chr(97)`` 回傳字串 " "``'a'``,而 ``chr(8364)`` 回傳字串 ``'€'``。這是 :func:`ord` 的逆函式。" -#: ../../library/functions.rst:251 +#: ../../library/functions.rst:253 msgid "" "The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in " "base 16). :exc:`ValueError` will be raised if it is outside that range." @@ -701,11 +706,11 @@ msgstr "" "引數的有效範圍是 0 到 1,114,111(16 進制表示為 0x10FFFF)。如果它超過這個範" "圍,會引發 :exc:`ValueError`。" -#: ../../library/functions.rst:257 +#: ../../library/functions.rst:259 msgid "Transform a method into a class method." msgstr "把一個 method 封裝成 class method(類別方法)。" -#: ../../library/functions.rst:259 +#: ../../library/functions.rst:261 msgid "" "A class method receives the class as an implicit first argument, just like " "an instance method receives the instance. To declare a class method, use " @@ -714,7 +719,7 @@ msgstr "" "一個 class method 把自己的 class 作為第一個引數,就像一個實例 method 把實例自" "己作為第一個引數。請用以下慣例來宣告 class method: ::" -#: ../../library/functions.rst:263 +#: ../../library/functions.rst:265 msgid "" "class C:\n" " @classmethod\n" @@ -724,7 +729,7 @@ msgstr "" " @classmethod\n" " def f(cls, arg1, arg2): ..." -#: ../../library/functions.rst:267 +#: ../../library/functions.rst:269 msgid "" "The ``@classmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." @@ -732,7 +737,7 @@ msgstr "" "``@classmethod`` 語法是一個函式 :term:`decorator` — 參見 :ref:`function` 中關" "於函式定義的詳細介紹。" -#: ../../library/functions.rst:270 +#: ../../library/functions.rst:272 msgid "" "A class method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). The instance is ignored except for its " @@ -743,7 +748,7 @@ msgstr "" "叫。實例除了它的 class 資訊,其他都會被忽略。如果一個 class method 在 " "subclass 上呼叫,subclass 會作為第一個引數傳入。" -#: ../../library/functions.rst:275 +#: ../../library/functions.rst:277 msgid "" "Class methods are different than C++ or Java static methods. If you want " "those, see :func:`staticmethod` in this section. For more information on " @@ -753,7 +758,7 @@ msgstr "" "method,請看本節的 :func:`staticmethod`。關於 class method 的更多資訊,請參考" "\\ :ref:`types`。" -#: ../../library/functions.rst:279 +#: ../../library/functions.rst:281 msgid "" "Class methods can now wrap other :term:`descriptors ` such as :" "func:`property`." @@ -761,7 +766,7 @@ msgstr "" "Class methods 現在可以包裝其他\\ :term:`描述器 `,例如 :func:" "`property`" -#: ../../library/functions.rst:283 +#: ../../library/functions.rst:285 msgid "" "Class methods now inherit the method attributes (:attr:`~function." "__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" @@ -773,7 +778,7 @@ msgstr "" "__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " "``__wrapped__`` 屬性。" -#: ../../library/functions.rst:290 +#: ../../library/functions.rst:292 msgid "" "Class methods can no longer wrap other :term:`descriptors ` such " "as :func:`property`." @@ -781,7 +786,7 @@ msgstr "" "Class methods 不能再包裝其他的\\ :term:`描述器 `,例如 :func:" "`property`。" -#: ../../library/functions.rst:297 +#: ../../library/functions.rst:299 msgid "" "Compile the *source* into a code or AST object. Code objects can be " "executed by :func:`exec` or :func:`eval`. *source* can either be a normal " @@ -792,7 +797,7 @@ msgstr "" "`eval` 執行。*source* 可以是一般的字串、bytes 字串、或者 AST 物件。參見 :mod:" "`ast` module(模組)的說明文件瞭解如何使用 AST 物件。" -#: ../../library/functions.rst:302 +#: ../../library/functions.rst:304 msgid "" "The *filename* argument should give the file from which the code was read; " "pass some recognizable value if it wasn't read from a file (``''`` " @@ -801,7 +806,7 @@ msgstr "" "*filename* 引數必須是程式碼的檔名;如果程式碼不是從檔案中讀取,可以傳入一些可" "辨識的值(經常會使用 ``''`` 來替代)。" -#: ../../library/functions.rst:306 +#: ../../library/functions.rst:308 msgid "" "The *mode* argument specifies what kind of code must be compiled; it can be " "``'exec'`` if *source* consists of a sequence of statements, ``'eval'`` if " @@ -814,7 +819,7 @@ msgstr "" "式,可以是 ``'single'``\\ (在最後一種情況下,如果運算式執行結果不是 " "``None`` 則會被印出來)。" -#: ../../library/functions.rst:312 +#: ../../library/functions.rst:314 msgid "" "The optional arguments *flags* and *dont_inherit* control which :ref:" "`compiler options ` should be activated and which :ref:" @@ -835,7 +840,7 @@ msgstr "" "數,則使用 *flags* 引數 -- 周圍程式碼中的旗標(未來功能和編譯器選項)將被忽" "略。" -#: ../../library/functions.rst:323 +#: ../../library/functions.rst:325 msgid "" "Compiler options and future statements are specified by bits which can be " "bitwise ORed together to specify multiple options. The bitfield required to " @@ -850,7 +855,7 @@ msgstr "" "compiler_flag` 屬性來獲得。:ref:`編譯器旗標 `\\ 可以在 :" "mod:`ast` module 中搜尋有 ``PyCF_`` 前綴的名稱。" -#: ../../library/functions.rst:331 +#: ../../library/functions.rst:333 msgid "" "The argument *optimize* specifies the optimization level of the compiler; " "the default value of ``-1`` selects the optimization level of the " @@ -863,20 +868,20 @@ msgstr "" "``__debug__`` 為真值)、``1``\\ (assert 被刪除,``__debug__`` 為假值)或 " "``2``\\ (說明字串 (docstring) 也被刪除)。" -#: ../../library/functions.rst:337 +#: ../../library/functions.rst:339 msgid "" "This function raises :exc:`SyntaxError` or :exc:`ValueError` if the compiled " "source is invalid." msgstr "" "如果編譯的原始碼無效,此函式會引發 :exc:`SyntaxError` 或 :exc:`ValueError`。" -#: ../../library/functions.rst:340 +#: ../../library/functions.rst:342 msgid "" "If you want to parse Python code into its AST representation, see :func:`ast." "parse`." msgstr "如果你想解析 Python 程式碼為 AST 運算式,請參閱 :func:`ast.parse`。" -#: ../../library/functions.rst:343 ../../library/functions.rst:345 +#: ../../library/functions.rst:345 ../../library/functions.rst:347 msgid "" "Raises an :ref:`auditing event ` ``compile`` with arguments " "``source`` and ``filename``. This event may also be raised by implicit " @@ -885,7 +890,7 @@ msgstr "" "引發一個附帶引數 ``source``、``filename`` 的\\ :ref:`稽核事件 ` " "``compile``。此事件也可能由隱式編譯 (implicit compilation) 所引發。" -#: ../../library/functions.rst:351 +#: ../../library/functions.rst:353 msgid "" "When compiling a string with multi-line code in ``'single'`` or ``'eval'`` " "mode, input must be terminated by at least one newline character. This is " @@ -895,7 +900,7 @@ msgstr "" "在 ``'single'`` 或 ``'eval'`` 模式編譯多行程式碼時,輸入必須以至少一個換行符" "結尾。這使 :mod:`code` module 更容易檢測陳述式的完整性。" -#: ../../library/functions.rst:358 +#: ../../library/functions.rst:360 msgid "" "It is possible to crash the Python interpreter with a sufficiently large/" "complex string when compiling to an AST object due to stack depth " @@ -904,7 +909,7 @@ msgstr "" "如果編譯足夠大或者足夠複雜的字串成 AST 物件時,Python 直譯器會因為 Python " "AST 編譯器的 stack 深度限制而崩潰。" -#: ../../library/functions.rst:362 +#: ../../library/functions.rst:364 msgid "" "Allowed use of Windows and Mac newlines. Also, input in ``'exec'`` mode " "does not have to end in a newline anymore. Added the *optimize* parameter." @@ -912,13 +917,13 @@ msgstr "" "允許使用 Windows 和 Mac 的換行符號。此外,在 ``'exec'`` 模式不需要以換行符號" "結尾。增加了 *optimize* 參數。" -#: ../../library/functions.rst:366 +#: ../../library/functions.rst:368 msgid "" "Previously, :exc:`TypeError` was raised when null bytes were encountered in " "*source*." msgstr "在之前的版本,*source* 中包含 null bytes 會引發 :exc:`TypeError`。" -#: ../../library/functions.rst:370 +#: ../../library/functions.rst:372 msgid "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable " "support for top-level ``await``, ``async for``, and ``async with``." @@ -926,18 +931,18 @@ msgstr "" "``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` 現在可以傳遞旗標以啟用對頂層 ``await``、" "``async for`` 和 ``async with`` 的支援。" -#: ../../library/functions.rst:379 +#: ../../library/functions.rst:381 msgid "" "Convert a single string or number to a complex number, or create a complex " "number from real and imaginary parts." msgstr "" -#: ../../library/functions.rst:382 ../../library/functions.rst:756 -#: ../../library/functions.rst:1004 +#: ../../library/functions.rst:384 ../../library/functions.rst:758 +#: ../../library/functions.rst:1006 msgid "Examples:" msgstr "例如: ::" -#: ../../library/functions.rst:384 +#: ../../library/functions.rst:386 msgid "" ">>> complex('+1.23')\n" "(1.23+0j)\n" @@ -973,7 +978,7 @@ msgstr "" ">>> complex(-1.23, 4.5)\n" "(-1.23+4.5j)" -#: ../../library/functions.rst:403 +#: ../../library/functions.rst:405 msgid "" "If the argument is a string, it must contain either a real part (in the same " "format as for :func:`float`) or an imaginary part (in the same format but " @@ -988,7 +993,7 @@ msgid "" "parentheses and leading and trailing whitespace characters are removed:" msgstr "" -#: ../../library/functions.rst:422 +#: ../../library/functions.rst:424 msgid "" "If the argument is a number, the constructor serves as a numeric conversion " "like :class:`int` and :class:`float`. For a general Python object ``x``, " @@ -1003,7 +1008,7 @@ msgstr "" "back) 到 :meth:`~object.__float__`。如果 :meth:`!__float__` 未定義,則會再回" "退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:431 +#: ../../library/functions.rst:433 msgid "" "If two arguments are provided or keyword arguments are used, each argument " "may be any numeric type (including complex). If both arguments are real " @@ -1014,26 +1019,26 @@ msgid "" "number, only its real component is used in the above expressions." msgstr "" -#: ../../library/functions.rst:441 +#: ../../library/functions.rst:443 msgid "" "See also :meth:`complex.from_number` which only accepts a single numeric " "argument." msgstr "" -#: ../../library/functions.rst:443 +#: ../../library/functions.rst:445 msgid "If all arguments are omitted, returns ``0j``." msgstr "" -#: ../../library/functions.rst:445 +#: ../../library/functions.rst:447 msgid "The complex type is described in :ref:`typesnumeric`." msgstr "複數型別在 :ref:`typesnumeric` 中有相關描述。" -#: ../../library/functions.rst:447 ../../library/functions.rst:810 -#: ../../library/functions.rst:1052 +#: ../../library/functions.rst:449 ../../library/functions.rst:812 +#: ../../library/functions.rst:1054 msgid "Grouping digits with underscores as in code literals is allowed." msgstr "可以使用底線將程式碼文字中的數字進行分組。" -#: ../../library/functions.rst:450 +#: ../../library/functions.rst:452 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and :" "meth:`~object.__float__` are not defined." @@ -1041,13 +1046,13 @@ msgstr "" "如果 :meth:`~object.__complex__` 和 :meth:`~object.__float__` 未定義,則會回" "退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:454 +#: ../../library/functions.rst:456 msgid "" "Passing a complex number as the *real* or *imag* argument is now deprecated; " "it should only be passed as a single positional argument." msgstr "" -#: ../../library/functions.rst:461 +#: ../../library/functions.rst:463 msgid "" "This is a relative of :func:`setattr`. The arguments are an object and a " "string. The string must be the name of one of the object's attributes. The " @@ -1060,7 +1065,7 @@ msgstr "" "'foobar')`` 等價於 ``del x.foobar``。*name* 不必是個 Python 識別符 " "(identifier)(請見 :func:`setattr`)。" -#: ../../library/functions.rst:474 +#: ../../library/functions.rst:476 msgid "" "Create a new dictionary. The :class:`dict` object is the dictionary class. " "See :class:`dict` and :ref:`typesmapping` for documentation about this class." @@ -1068,7 +1073,7 @@ msgstr "" "建立一個新的 dictionary(字典)。:class:`dict` 物件是一個 dictionary class。" "參見 :class:`dict` 和 :ref:`typesmapping` 來瞭解這個 class。" -#: ../../library/functions.rst:477 +#: ../../library/functions.rst:479 msgid "" "For other containers see the built-in :class:`list`, :class:`set`, and :" "class:`tuple` classes, as well as the :mod:`collections` module." @@ -1076,7 +1081,7 @@ msgstr "" "其他容器型別,請參見內建的 :class:`list`、:class:`set` 和 :class:`tuple` " "class,以及 :mod:`collections` module。" -#: ../../library/functions.rst:484 +#: ../../library/functions.rst:486 msgid "" "Without arguments, return the list of names in the current local scope. " "With an argument, attempt to return a list of valid attributes for that " @@ -1085,7 +1090,7 @@ msgstr "" "如果沒有引數,則回傳目前區域作用域 (local scope) 中的名稱列表。如果有引數,它" "會嘗試回傳該物件的有效屬性列表。" -#: ../../library/functions.rst:487 +#: ../../library/functions.rst:489 msgid "" "If the object has a method named :meth:`~object.__dir__`, this method will " "be called and must return the list of attributes. This allows objects that " @@ -1094,11 +1099,11 @@ msgid "" "attributes." msgstr "" "如果物件有一個名為 :meth:`~object.__dir__` 的 method,那麼該 method 將被呼" -"叫,並且必須回傳一個屬性列表。這允許實現自訂 :func:`~object.__getattr__` " -"或 :func:`~object.__getattribute__` 函式的物件能夠自訂 :func:`dir` 來報告它" -"們的屬性。" +"叫,並且必須回傳一個屬性列表。這允許實現自訂 :func:`~object.__getattr__` 或 :" +"func:`~object.__getattribute__` 函式的物件能夠自訂 :func:`dir` 來報告它們的屬" +"性。" -#: ../../library/functions.rst:494 +#: ../../library/functions.rst:496 msgid "" "If the object does not provide :meth:`~object.__dir__`, the function tries " "its best to gather information from the object's :attr:`~object.__dict__` " @@ -1110,7 +1115,7 @@ msgstr "" "`~object.__dict__` 屬性和型別物件收集資訊。結果列表並不總是完整的,如果物件有" "自訂 :func:`~object.__getattr__`,那結果可能不準確。" -#: ../../library/functions.rst:500 +#: ../../library/functions.rst:502 msgid "" "The default :func:`dir` mechanism behaves differently with different types " "of objects, as it attempts to produce the most relevant, rather than " @@ -1119,13 +1124,13 @@ msgstr "" "預設的 :func:`dir` 機制對不同型別的物件有不同行為,它會試圖回傳最相關而非最完" "整的資訊:" -#: ../../library/functions.rst:504 +#: ../../library/functions.rst:506 msgid "" "If the object is a module object, the list contains the names of the " "module's attributes." msgstr "如果物件是 module 物件,則列表包含 module 的屬性名稱。" -#: ../../library/functions.rst:507 +#: ../../library/functions.rst:509 msgid "" "If the object is a type or class object, the list contains the names of its " "attributes, and recursively of the attributes of its bases." @@ -1133,7 +1138,7 @@ msgstr "" "如果物件是型別或 class 物件,則列表包含它們的屬性名稱,並且遞迴查詢其基礎的所" "有屬性。" -#: ../../library/functions.rst:510 +#: ../../library/functions.rst:512 msgid "" "Otherwise, the list contains the object's attributes' names, the names of " "its class's attributes, and recursively of the attributes of its class's " @@ -1142,11 +1147,11 @@ msgstr "" "否則,包含物件的屬性名稱列表、它的 class 屬性名稱,並且遞迴查詢它的 class 的" "所有基礎 class 的屬性。" -#: ../../library/functions.rst:514 +#: ../../library/functions.rst:516 msgid "The resulting list is sorted alphabetically. For example:" msgstr "回傳的列表按字母表排序,例如:" -#: ../../library/functions.rst:534 +#: ../../library/functions.rst:536 msgid "" "Because :func:`dir` is supplied primarily as a convenience for use at an " "interactive prompt, it tries to supply an interesting set of names more than " @@ -1159,7 +1164,7 @@ msgstr "" "版本之間改變。例如,當引數是一個 class 時,metaclass 的屬性不包含在結果列表" "中。" -#: ../../library/functions.rst:544 +#: ../../library/functions.rst:546 msgid "" "Take two (non-complex) numbers as arguments and return a pair of numbers " "consisting of their quotient and remainder when using integer division. " @@ -1177,7 +1182,7 @@ msgstr "" "等,如果 ``a % b`` 非零,則它的符號和 *b* 一樣,且 ``0 <= abs(a % b) < " "abs(b)``。" -#: ../../library/functions.rst:556 +#: ../../library/functions.rst:558 msgid "" "Return an enumerate object. *iterable* must be a sequence, an :term:" "`iterator`, or some other object which supports iteration. The :meth:" @@ -1190,11 +1195,11 @@ msgstr "" "__next__` method 回傳一個 tuple(元組),裡面包含一個計數值(從 *start* 開" "始,預設為 0)和透過疊代 *iterable* 獲得的值。" -#: ../../library/functions.rst:568 +#: ../../library/functions.rst:570 msgid "Equivalent to::" msgstr "等價於: ::" -#: ../../library/functions.rst:570 +#: ../../library/functions.rst:572 msgid "" "def enumerate(iterable, start=0):\n" " n = start\n" @@ -1212,15 +1217,15 @@ msgstr "" msgid "Parameters" msgstr "" -#: ../../library/functions.rst:580 +#: ../../library/functions.rst:582 msgid "A Python expression." msgstr "" -#: ../../library/functions.rst:584 +#: ../../library/functions.rst:586 msgid "The global namespace (default: ``None``)." msgstr "" -#: ../../library/functions.rst:588 +#: ../../library/functions.rst:590 msgid "The local namespace (default: ``None``)." msgstr "" @@ -1228,7 +1233,7 @@ msgstr "" msgid "Returns" msgstr "" -#: ../../library/functions.rst:592 +#: ../../library/functions.rst:594 msgid "The result of the evaluated expression." msgstr "" @@ -1236,17 +1241,17 @@ msgstr "" msgid "raises" msgstr "引發" -#: ../../library/functions.rst:593 +#: ../../library/functions.rst:595 msgid "Syntax errors are reported as exceptions." msgstr "" -#: ../../library/functions.rst:597 ../../library/functions.rst:658 +#: ../../library/functions.rst:599 ../../library/functions.rst:660 msgid "" "This function executes arbitrary code. Calling it with user-supplied input " "may lead to security vulnerabilities." msgstr "" -#: ../../library/functions.rst:600 +#: ../../library/functions.rst:602 msgid "" "The *source* argument is parsed and evaluated as a Python expression " "(technically speaking, a condition list) using the *globals* and *locals* " @@ -1264,23 +1269,23 @@ msgid "" "referenced in the scope that is calling :func:`eval` (e.g. via a :keyword:" "`nonlocal` statement)." msgstr "" -"*source* 引數會被視為一條 Python 運算式(技術上而言,是條件列表)來剖析及" -"求值,而 *globals* 和 *locals* 對映分別用作全域和區域命名空間。如果 " -"*globals* dictionary 存在但缺少 ``__builtins__`` 的鍵值,那 *source* 被剖" -"析之前,將為該鍵插入對內建 :mod:`builtins` module dictionary 的引用。這麼一" -"來,在將 ``__builtins__`` dictionary 傳入 :func:`eval` 之前,你可以透過將它插" -"入 *globals* 來控制你需要哪些內建函式來執行程式碼。如果 *locals* 對映被省略," -"那它的預設值是 *globals* dictionary。如果兩個對映都被省略,則以在 :func:" -"`eval` 被呼叫的環境中的 *globals* 和 *locals* 執行原始碼。請注意,*eval()* 在" -"封閉 (enclosing) 環境中無法存取\\ :term:`巢狀作用域 ` (non-" -"locals),除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透過 :keyword:" -"`nonlocal` 陳述式)。" - -#: ../../library/functions.rst:616 +"*source* 引數會被視為一條 Python 運算式(技術上而言,是條件列表)來剖析及求" +"值,而 *globals* 和 *locals* 對映分別用作全域和區域命名空間。如果 *globals* " +"dictionary 存在但缺少 ``__builtins__`` 的鍵值,那 *source* 被剖析之前,將為該" +"鍵插入對內建 :mod:`builtins` module dictionary 的引用。這麼一來,在將 " +"``__builtins__`` dictionary 傳入 :func:`eval` 之前,你可以透過將它插入 " +"*globals* 來控制你需要哪些內建函式來執行程式碼。如果 *locals* 對映被省略,那" +"它的預設值是 *globals* dictionary。如果兩個對映都被省略,則以在 :func:`eval` " +"被呼叫的環境中的 *globals* 和 *locals* 執行原始碼。請注意,*eval()* 在封閉 " +"(enclosing) 環境中無法存取\\ :term:`巢狀作用域 ` (non-locals)," +"除非呼叫 :func:`eval` 的作用域已經有參照它們(例如透過 :keyword:`nonlocal` 陳" +"述式)。" + +#: ../../library/functions.rst:618 msgid "Example:" msgstr "範例:" -#: ../../library/functions.rst:622 +#: ../../library/functions.rst:624 msgid "" "This function can also be used to execute arbitrary code objects (such as " "those created by :func:`compile`). In this case, pass a code object instead " @@ -1291,7 +1296,7 @@ msgstr "" "情況下,傳入的引數是程式碼物件而不是字串。如果編譯該物件時的 *mode* 引數是 " "``'exec'``,那麼 :func:`eval` 回傳值為 ``None``。" -#: ../../library/functions.rst:627 +#: ../../library/functions.rst:629 msgid "" "Hints: dynamic execution of statements is supported by the :func:`exec` " "function. The :func:`globals` and :func:`locals` functions return the " @@ -1302,13 +1307,13 @@ msgstr "" "函式分別回傳目前的全域性和局部性 dictionary,它們對於將引數傳遞給 :func:" "`eval` 或 :func:`exec` 可能會方便許多。" -#: ../../library/functions.rst:632 +#: ../../library/functions.rst:634 msgid "" "If the given source is a string, then leading and trailing spaces and tabs " "are stripped." msgstr "如果給定來源是一個字串,那麼其前後的空格和定位字元會被移除。" -#: ../../library/functions.rst:635 +#: ../../library/functions.rst:637 msgid "" "See :func:`ast.literal_eval` for a function that can safely evaluate strings " "with expressions containing only literals." @@ -1316,8 +1321,8 @@ msgstr "" "另外可以參閱 :func:`ast.literal_eval`,該函式可以安全執行僅包含文字的運算式字" "串。" -#: ../../library/functions.rst:638 ../../library/functions.rst:640 -#: ../../library/functions.rst:700 ../../library/functions.rst:702 +#: ../../library/functions.rst:640 ../../library/functions.rst:642 +#: ../../library/functions.rst:702 ../../library/functions.rst:704 msgid "" "Raises an :ref:`auditing event ` ``exec`` with the code object as " "the argument. Code compilation events may also be raised." @@ -1325,17 +1330,17 @@ msgstr "" "引發一個附帶程式碼物件為引數的\\ :ref:`稽核事件 ` ``exec``。也可能" "會引發程式碼編譯事件。" -#: ../../library/functions.rst:645 ../../library/functions.rst:722 +#: ../../library/functions.rst:647 ../../library/functions.rst:724 msgid "The *globals* and *locals* arguments can now be passed as keywords." msgstr "" -#: ../../library/functions.rst:649 ../../library/functions.rst:726 +#: ../../library/functions.rst:651 ../../library/functions.rst:728 msgid "" "The semantics of the default *locals* namespace have been adjusted as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:661 +#: ../../library/functions.rst:663 msgid "" "This function supports dynamic execution of Python code. *source* must be " "either a string or a code object. If it is a string, the string is parsed " @@ -1355,7 +1360,7 @@ msgstr "" "`nonlocal`、:keyword:`yield` 和 :keyword:`return` 陳述式也不能在函式之外使" "用。該函式回傳值是 ``None``。" -#: ../../library/functions.rst:672 +#: ../../library/functions.rst:674 msgid "" "In all cases, if the optional parts are omitted, the code is executed in the " "current scope. If only *globals* is provided, it must be a dictionary (and " @@ -1371,7 +1376,7 @@ msgstr "" "用作全域和區域變數。如果提供了 *locals*,則它可以是任何對映物件。請記住在 " "module 層級中全域和區域變數是相同的 dictionary。" -#: ../../library/functions.rst:682 +#: ../../library/functions.rst:684 msgid "" "When ``exec`` gets two separate objects as *globals* and *locals*, the code " "will be executed as if it were embedded in a class definition. This means " @@ -1380,7 +1385,7 @@ msgid "" "are treated as class variables in a class definition)." msgstr "" -#: ../../library/functions.rst:688 +#: ../../library/functions.rst:690 msgid "" "If the *globals* dictionary does not contain a value for the key " "``__builtins__``, a reference to the dictionary of the built-in module :mod:" @@ -1393,7 +1398,7 @@ msgstr "" "dictionary 傳入 :func:`exec` 之前,你可以透過將它插入 *globals* 來控制你需要" "哪些內建函式來執行程式碼。" -#: ../../library/functions.rst:694 +#: ../../library/functions.rst:696 msgid "" "The *closure* argument specifies a closure--a tuple of cellvars. It's only " "valid when the *object* is a code object containing :term:`free (closure) " @@ -1405,7 +1410,7 @@ msgstr "" "variables) ` 的程式碼物件時,它才有效。Tuple 的長度必須與程" "式碼物件的 :attr:`~codeobject.co_freevars` 屬性完全匹配。" -#: ../../library/functions.rst:707 +#: ../../library/functions.rst:709 msgid "" "The built-in functions :func:`globals` and :func:`locals` return the current " "global and local namespace, respectively, which may be useful to pass around " @@ -1414,7 +1419,7 @@ msgstr "" "內建 :func:`globals` 和 :func:`locals` 函式各自回傳目前的全域和區域命名空間," "因此可以將它們傳遞給 :func:`exec` 的第二個和第三個引數以供後續使用。" -#: ../../library/functions.rst:713 +#: ../../library/functions.rst:715 msgid "" "The default *locals* act as described for function :func:`locals` below. " "Pass an explicit *locals* dictionary if you need to see effects of the code " @@ -1424,11 +1429,11 @@ msgstr "" "func:`exec` 函式回傳時知道程式碼對 *locals* 的變動,請明確地傳遞 *locals* " "dictionary 。" -#: ../../library/functions.rst:717 +#: ../../library/functions.rst:719 msgid "Added the *closure* parameter." msgstr "增加了 *closure* 參數。" -#: ../../library/functions.rst:732 +#: ../../library/functions.rst:734 msgid "" "Construct an iterator from those elements of *iterable* for which *function* " "is true. *iterable* may be either a sequence, a container which supports " @@ -1440,7 +1445,7 @@ msgstr "" "*function* 是 ``None``,則會假設它是一個識別性函式,即 *iterable* 中所有假值" "元素會被移除。" -#: ../../library/functions.rst:738 +#: ../../library/functions.rst:740 msgid "" "Note that ``filter(function, iterable)`` is equivalent to the generator " "expression ``(item for item in iterable if function(item))`` if function is " @@ -1451,7 +1456,7 @@ msgstr "" "是 ``None`` 的時候為 ``(item for item in iterable if function(item))``;" "function 是 ``None`` 的時候為 ``(item for item in iterable if item)``。" -#: ../../library/functions.rst:743 +#: ../../library/functions.rst:745 msgid "" "See :func:`itertools.filterfalse` for the complementary function that " "returns elements of *iterable* for which *function* is false." @@ -1459,11 +1464,11 @@ msgstr "" "請參閱 :func:`itertools.filterfalse`,只有 *function* 為 false 時才選取 " "*iterable* 中元素的互補函式。" -#: ../../library/functions.rst:754 +#: ../../library/functions.rst:756 msgid "Return a floating-point number constructed from a number or a string." msgstr "回傳從數字或字串生成的浮點數。" -#: ../../library/functions.rst:758 +#: ../../library/functions.rst:760 msgid "" ">>> float('+1.23')\n" "1.23\n" @@ -1487,7 +1492,7 @@ msgstr "" ">>> float('-Infinity')\n" "-inf" -#: ../../library/functions.rst:771 +#: ../../library/functions.rst:773 msgid "" "If the argument is a string, it should contain a decimal number, optionally " "preceded by a sign, and optionally embedded in whitespace. The optional " @@ -1502,7 +1507,7 @@ msgstr "" "數也可以是 NaN(非數字)或正負無窮大的字串。確切地說,除去首尾的空格後,輸入" "必須遵循以下語法中 :token:`~float:floatvalue` 的生成規則:" -#: ../../library/functions.rst:792 +#: ../../library/functions.rst:794 msgid "" "Case is not significant, so, for example, \"inf\", \"Inf\", \"INFINITY\", " "and \"iNfINity\" are all acceptable spellings for positive infinity." @@ -1510,7 +1515,7 @@ msgstr "" "字母大小寫不影響,例如,\"inf\"、\"Inf\"、\"INFINITY\"、\"iNfINity\" 都可以表" "示正無窮大。" -#: ../../library/functions.rst:795 +#: ../../library/functions.rst:797 msgid "" "Otherwise, if the argument is an integer or a floating-point number, a " "floating-point number with the same value (within Python's floating-point " @@ -1520,7 +1525,7 @@ msgstr "" "否則,如果引數是整數或浮點數,則回傳具有相同值(在 Python 浮點精度範圍內)的" "浮點數。如果引數在 Python 浮點精度範圍外,則會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:800 +#: ../../library/functions.rst:802 msgid "" "For a general Python object ``x``, ``float(x)`` delegates to ``x." "__float__()``. If :meth:`~object.__float__` is not defined then it falls " @@ -1529,27 +1534,27 @@ msgstr "" "對於一般的 Python 物件 ``x``,``float(x)`` 會委派給 ``x.__float__()``。如果未" "定義 :meth:`~object.__float__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:804 +#: ../../library/functions.rst:806 msgid "" "See also :meth:`float.from_number` which only accepts a numeric argument." msgstr "" -#: ../../library/functions.rst:806 +#: ../../library/functions.rst:808 msgid "If no argument is given, ``0.0`` is returned." msgstr "如果沒有引數,則回傳 ``0.0``。" -#: ../../library/functions.rst:808 +#: ../../library/functions.rst:810 msgid "The float type is described in :ref:`typesnumeric`." msgstr ":ref:`typesnumeric` 描述了浮點數型別。" -#: ../../library/functions.rst:816 +#: ../../library/functions.rst:818 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not " "defined." msgstr "" "如果 :meth:`~object.__float__` 未定義,則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:826 +#: ../../library/functions.rst:828 msgid "" "Convert a *value* to a \"formatted\" representation, as controlled by " "*format_spec*. The interpretation of *format_spec* will depend on the type " @@ -1560,7 +1565,7 @@ msgstr "" "取決於 *value* 引數的型別,但是大多數內建型別使用標準格式化語法::ref:" "`formatspec`。" -#: ../../library/functions.rst:831 +#: ../../library/functions.rst:833 msgid "" "The default *format_spec* is an empty string which usually gives the same " "effect as calling :func:`str(value) `." @@ -1568,7 +1573,7 @@ msgstr "" "預設的 *format_spec* 是一個空字串,它通常和呼叫 :func:`str(value) ` 的效" "果相同。" -#: ../../library/functions.rst:834 +#: ../../library/functions.rst:836 msgid "" "A call to ``format(value, format_spec)`` is translated to ``type(value)." "__format__(value, format_spec)`` which bypasses the instance dictionary when " @@ -1582,7 +1587,7 @@ msgstr "" "實例中的字典。如果搜尋到 :mod:`object` 這個 method 但 *format_spec* 不為空," "或是 *format_spec* 或回傳值不是字串,則會引發 :exc:`TypeError`。" -#: ../../library/functions.rst:841 +#: ../../library/functions.rst:843 msgid "" "``object().__format__(format_spec)`` raises :exc:`TypeError` if " "*format_spec* is not an empty string." @@ -1590,7 +1595,7 @@ msgstr "" "當 *format_spec* 不是空字串時,``object().__format__(format_spec)`` 會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:850 +#: ../../library/functions.rst:852 msgid "" "Return a new :class:`frozenset` object, optionally with elements taken from " "*iterable*. ``frozenset`` is a built-in class. See :class:`frozenset` and :" @@ -1600,7 +1605,7 @@ msgstr "" "``frozenset`` 是一個內建的 class。有關此 class 的文件,請參閱 :class:" "`frozenset` 和 :ref:`types-set`。" -#: ../../library/functions.rst:854 +#: ../../library/functions.rst:856 msgid "" "For other containers see the built-in :class:`set`, :class:`list`, :class:" "`tuple`, and :class:`dict` classes, as well as the :mod:`collections` module." @@ -1608,7 +1613,7 @@ msgstr "" "請參閱內建的 :class:`set`、:class:`list`、:class:`tuple` 和 :class:`dict` " "class,以及 :mod:`collections` module 來了解其它的容器。" -#: ../../library/functions.rst:862 +#: ../../library/functions.rst:864 msgid "" "Return the value of the named attribute of *object*. *name* must be a " "string. If the string is the name of one of the object's attributes, the " @@ -1623,7 +1628,7 @@ msgstr "" "`AttributeError`。*name* 不必是個 Python 識別符 (identifier)(請見 :func:" "`setattr`)。" -#: ../../library/functions.rst:871 +#: ../../library/functions.rst:873 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " @@ -1634,7 +1639,7 @@ msgstr "" "發生在編譯期,因此你必須手動改編私有屬性(有兩個前導底線的屬性)的名稱,才能" "使用 :func:`getattr` 來取得它。" -#: ../../library/functions.rst:879 +#: ../../library/functions.rst:881 msgid "" "Return the dictionary implementing the current module namespace. For code " "within functions, this is set when the function is defined and remains the " @@ -1643,7 +1648,7 @@ msgstr "" "回傳代表目前 module 命名空間的 dictionary。對於在函式中的程式碼來說,這在定義" "函式時設定且不論該函式是在何處呼叫都會保持相同。" -#: ../../library/functions.rst:886 +#: ../../library/functions.rst:888 msgid "" "The arguments are an object and a string. The result is ``True`` if the " "string is the name of one of the object's attributes, ``False`` if not. " @@ -1654,7 +1659,7 @@ msgstr "" "則回傳 ``False``。(此功能是透過呼叫 ``getattr(object, name)`` 並檢查是否引" "發 :exc:`AttributeError` 來實作的。)" -#: ../../library/functions.rst:894 +#: ../../library/functions.rst:896 msgid "" "Return the hash value of the object (if it has one). Hash values are " "integers. They are used to quickly compare dictionary keys during a " @@ -1665,7 +1670,7 @@ msgstr "" "時用來快速比較 dictionary 的鍵。相同大小的數字數值有相同的雜湊值(即使它們型" "別不同,如 1 和 1.0)。" -#: ../../library/functions.rst:901 +#: ../../library/functions.rst:903 msgid "" "For objects with custom :meth:`~object.__hash__` methods, note that :func:" "`hash` truncates the return value based on the bit width of the host machine." @@ -1673,7 +1678,7 @@ msgstr "" "請注意,如果物件帶有自訂的 :meth:`~object.__hash__` 方法,:func:`hash` 將根據" "運行機器的位元長度來截斷回傳值。" -#: ../../library/functions.rst:908 +#: ../../library/functions.rst:910 msgid "" "Invoke the built-in help system. (This function is intended for interactive " "use.) If no argument is given, the interactive help system starts on the " @@ -1687,7 +1692,7 @@ msgstr "" "關鍵字或說明文件主題中搜尋該字串,並在控制台上列印幫助資訊。如果引數是其他任" "意物件,則會生成該物件的幫助頁。" -#: ../../library/functions.rst:915 +#: ../../library/functions.rst:917 msgid "" "Note that if a slash(/) appears in the parameter list of a function when " "invoking :func:`help`, it means that the parameters prior to the slash are " @@ -1698,12 +1703,12 @@ msgstr "" "前面的參數是僅限位置 (positional-only) 參數。有關更多資訊,請參閱\\ :ref:`常" "見問答集中的僅限位置參數條目 `。" -#: ../../library/functions.rst:920 +#: ../../library/functions.rst:922 msgid "" "This function is added to the built-in namespace by the :mod:`site` module." msgstr "此函式會被 :mod:`site` module 加入到內建命名空間。" -#: ../../library/functions.rst:922 +#: ../../library/functions.rst:924 msgid "" "Changes to :mod:`pydoc` and :mod:`inspect` mean that the reported signatures " "for callables are now more comprehensive and consistent." @@ -1711,7 +1716,7 @@ msgstr "" "對於 :mod:`pydoc` 和 :mod:`inspect` 的變更,使得可呼叫物件回報的的簽名 " "(signature) 更加全面和一致。" -#: ../../library/functions.rst:929 +#: ../../library/functions.rst:931 msgid "" "Convert an integer number to a lowercase hexadecimal string prefixed with " "\"0x\". If *integer* is not a Python :class:`int` object, it has to define " @@ -1721,7 +1726,7 @@ msgstr "" "Python :class:`int` 物件,則必須定義一個 :meth:`~object.__index__` method 並" "且回傳一個整數。舉例來說:" -#: ../../library/functions.rst:938 +#: ../../library/functions.rst:940 msgid "" "If you want to convert an integer number to an uppercase or lower " "hexadecimal string with prefix or not, you can use either of the following " @@ -1730,20 +1735,20 @@ msgstr "" "如果要將整數轉換為大寫或小寫的十六進位制字串,並可選擇有無 \"0x\" 前綴,則可" "以使用如下方法:" -#: ../../library/functions.rst:950 +#: ../../library/functions.rst:952 msgid "" "See also :func:`int` for converting a hexadecimal string to an integer using " "a base of 16." msgstr "另請參閱 :func:`int` 將十六進位制字串轉換為以 16 為基數的整數。" -#: ../../library/functions.rst:955 +#: ../../library/functions.rst:957 msgid "" "To obtain a hexadecimal string representation for a float, use the :meth:" "`float.hex` method." msgstr "" "如果要取得浮點數的十六進位制字串形式,請使用 :meth:`float.hex` method。" -#: ../../library/functions.rst:961 +#: ../../library/functions.rst:963 msgid "" "Return the \"identity\" of an object. This is an integer which is " "guaranteed to be unique and constant for this object during its lifetime. " @@ -1753,18 +1758,18 @@ msgstr "" "回傳物件的 \"識別性\" 。該值是一個整數,在此物件的生命週期中保證是唯一且恆定" "的。兩個生命期不重疊的物件可能具有相同的 :func:`id` 值。" -#: ../../library/functions.rst:966 +#: ../../library/functions.rst:968 msgid "This is the address of the object in memory." msgstr "這是該物件在記憶體中的位址。" -#: ../../library/functions.rst:968 +#: ../../library/functions.rst:970 msgid "" "Raises an :ref:`auditing event ` ``builtins.id`` with argument " "``id``." msgstr "" "引發一個附帶引數 ``id`` 的\\ :ref:`稽核事件 ` ``builtins.id``。" -#: ../../library/functions.rst:974 +#: ../../library/functions.rst:976 msgid "" "If the *prompt* argument is present, it is written to standard output " "without a trailing newline. The function then reads a line from input, " @@ -1775,7 +1780,7 @@ msgstr "" "從輸入中讀取一行,將其轉換為字串(去除末尾的換行符)並回傳。當讀取到 EOF 時," "則引發 :exc:`EOFError`。例如: ::" -#: ../../library/functions.rst:979 +#: ../../library/functions.rst:981 msgid "" ">>> s = input('--> ')\n" "--> Monty Python's Flying Circus\n" @@ -1787,7 +1792,7 @@ msgstr "" ">>> s\n" "\"Monty Python's Flying Circus\"" -#: ../../library/functions.rst:984 +#: ../../library/functions.rst:986 msgid "" "If the :mod:`readline` module was loaded, then :func:`input` will use it to " "provide elaborate line editing and history features." @@ -1795,7 +1800,7 @@ msgstr "" "如果載入了 :mod:`readline` module,:func:`input` 將使用它來提供複雜的行編輯和" "歷史記錄功能。" -#: ../../library/functions.rst:987 ../../library/functions.rst:989 +#: ../../library/functions.rst:989 ../../library/functions.rst:991 msgid "" "Raises an :ref:`auditing event ` ``builtins.input`` with argument " "``prompt`` before reading input" @@ -1803,7 +1808,7 @@ msgstr "" "引發一個附帶讀取輸入前的引數 ``prompt`` 的\\ :ref:`稽核事件 ` " "``builtins.input``。" -#: ../../library/functions.rst:992 ../../library/functions.rst:994 +#: ../../library/functions.rst:994 ../../library/functions.rst:996 msgid "" "Raises an :ref:`auditing event ` ``builtins.input/result`` with " "the result after successfully reading input." @@ -1811,13 +1816,13 @@ msgstr "" "引發一個附帶成功讀取結果的\\ :ref:`稽核事件 ` ``builtins.input/" "result``。" -#: ../../library/functions.rst:1001 +#: ../../library/functions.rst:1003 msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." msgstr "" -#: ../../library/functions.rst:1006 +#: ../../library/functions.rst:1008 msgid "" ">>> int(123.45)\n" "123\n" @@ -1845,7 +1850,7 @@ msgstr "" ">>> int('01110011', base=2)\n" "115" -#: ../../library/functions.rst:1021 +#: ../../library/functions.rst:1023 msgid "" "If the argument defines :meth:`~object.__int__`, ``int(x)`` returns ``x." "__int__()``. If the argument defines :meth:`~object.__index__`, it returns " @@ -1855,7 +1860,7 @@ msgstr "" "__int__()``。如果引數定義了 :meth:`~object.__index__` 則回傳 ``x." "__index__()``。對於浮點數,則會向零的方向無條件捨去。" -#: ../../library/functions.rst:1026 +#: ../../library/functions.rst:1028 msgid "" "If the argument is not a number or if *base* is given, then it must be a " "string, :class:`bytes`, or :class:`bytearray` instance representing an " @@ -1868,7 +1873,7 @@ msgstr "" "以有 ``+`` 或 ``-``\\ (中間沒有空格)、可有個前導的零、也可被空格包圍、或在" "數字間有單一底線。" -#: ../../library/functions.rst:1032 +#: ../../library/functions.rst:1034 msgid "" "A base-n integer string contains digits, each representing a value from 0 to " "n-1. The values 0--9 can be represented by any Unicode decimal digit. The " @@ -1890,11 +1895,11 @@ msgstr "" "進制中的一個,所以 ``int('010', 0)`` 是非法的,但 ``int('010')`` 和 " "``int('010', 8)`` 是有效的。" -#: ../../library/functions.rst:1043 +#: ../../library/functions.rst:1045 msgid "The integer type is described in :ref:`typesnumeric`." msgstr "整數型別定義請參閱\\ :ref:`typesnumeric`。" -#: ../../library/functions.rst:1045 +#: ../../library/functions.rst:1047 msgid "" "If *base* is not an instance of :class:`int` and the *base* object has a :" "meth:`base.__index__ ` method, that method is called to " @@ -1906,18 +1911,18 @@ msgstr "" "的版本使用 :meth:`base.__int__ ` 而不是 :meth:`base." "__index__ `。" -#: ../../library/functions.rst:1055 +#: ../../library/functions.rst:1057 msgid "The first parameter is now positional-only." msgstr "第一個參數為僅限位置參數。" -#: ../../library/functions.rst:1058 +#: ../../library/functions.rst:1060 msgid "" "Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not " "defined." msgstr "" "如果未定義 :meth:`~object.__int__` 則會回退到 :meth:`~object.__index__`。" -#: ../../library/functions.rst:1061 +#: ../../library/functions.rst:1063 msgid "" ":class:`int` string inputs and string representations can be limited to help " "avoid denial of service attacks. A :exc:`ValueError` is raised when the " @@ -1931,12 +1936,12 @@ msgstr "" "`int` 轉換為字串時將會超出限制時,會引發 :exc:`ValueError`。請參閱\\ :ref:`整" "數字串轉換的長度限制 `\\ 說明文件。" -#: ../../library/functions.rst:1069 +#: ../../library/functions.rst:1071 msgid "" ":func:`int` no longer delegates to the :meth:`~object.__trunc__` method." msgstr ":func:`int` 不再委派給 :meth:`~object.__trunc__` method。" -#: ../../library/functions.rst:1074 +#: ../../library/functions.rst:1076 msgid "" "Return ``True`` if the *object* argument is an instance of the *classinfo* " "argument, or of a (direct, indirect, or :term:`virtual `) of *classinfo*. A class is considered a " @@ -1976,7 +1981,7 @@ msgstr "" "是 *classinfo* 中任一元素的 subclass 時則回傳 ``True``。其他情況,會引發 :" "exc:`TypeError`。" -#: ../../library/functions.rst:1106 +#: ../../library/functions.rst:1108 msgid "" "Return an :term:`iterator` object. The first argument is interpreted very " "differently depending on the presence of the second argument. Without a " @@ -2000,11 +2005,11 @@ msgstr "" "__next__` 時會不帶引數地呼叫 *callable*;如果回傳的結果是 *sentinel* 則引發 :" "exc:`StopIteration`,否則回傳呼叫結果。" -#: ../../library/functions.rst:1120 +#: ../../library/functions.rst:1122 msgid "See also :ref:`typeiter`." msgstr "另請參閱 :ref:`typeiter`。" -#: ../../library/functions.rst:1122 +#: ../../library/functions.rst:1124 msgid "" "One useful application of the second form of :func:`iter` is to build a " "block-reader. For example, reading fixed-width blocks from a binary database " @@ -2013,7 +2018,7 @@ msgstr "" ":func:`iter` 的第二種形式有一個好用的應用,是能夠建立一個區塊閱讀器 (block-" "reader)。例如,從二進位資料庫檔案中讀取固定寬度的區塊,直到檔案的結尾: ::" -#: ../../library/functions.rst:1126 +#: ../../library/functions.rst:1128 msgid "" "from functools import partial\n" "with open('mydata.db', 'rb') as f:\n" @@ -2025,7 +2030,7 @@ msgstr "" " for block in iter(partial(f.read, 64), b''):\n" " process_block(block)" -#: ../../library/functions.rst:1134 +#: ../../library/functions.rst:1136 msgid "" "Return the length (the number of items) of an object. The argument may be a " "sequence (such as a string, bytes, tuple, list, or range) or a collection " @@ -2034,7 +2039,7 @@ msgstr "" "回傳物件的長度(元素個數)。引數可以是序列(如 string、bytes、tuple、list 或 " "range)或集合(如 dictionary、set 或 frozen set)。" -#: ../../library/functions.rst:1140 +#: ../../library/functions.rst:1142 msgid "" "``len`` raises :exc:`OverflowError` on lengths larger than :data:`sys." "maxsize`, such as :class:`range(2 ** 100) `." @@ -2042,7 +2047,7 @@ msgstr "" "如果物件長度大於 :data:`sys.maxsize`,像是 :class:`range(2 ** 100) `," "則 ``len`` 會引發 :exc:`OverflowError`。" -#: ../../library/functions.rst:1148 +#: ../../library/functions.rst:1150 msgid "" "Rather than being a function, :class:`list` is actually a mutable sequence " "type, as documented in :ref:`typesseq-list` and :ref:`typesseq`." @@ -2050,33 +2055,33 @@ msgstr "" "除了是函式,:class:`list` 也是可變序列型別,詳情請參閱 :ref:`typesseq-list` " "和 :ref:`typesseq`。" -#: ../../library/functions.rst:1154 +#: ../../library/functions.rst:1156 msgid "" "Return a mapping object representing the current local symbol table, with " "variable names as the keys, and their currently bound references as the " "values." msgstr "" -#: ../../library/functions.rst:1158 +#: ../../library/functions.rst:1160 msgid "" "At module scope, as well as when using :func:`exec` or :func:`eval` with a " "single namespace, this function returns the same namespace as :func:" "`globals`." msgstr "" -#: ../../library/functions.rst:1162 +#: ../../library/functions.rst:1164 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." msgstr "" -#: ../../library/functions.rst:1165 +#: ../../library/functions.rst:1167 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." msgstr "" -#: ../../library/functions.rst:1168 +#: ../../library/functions.rst:1170 msgid "" "In all of the above cases, each call to ``locals()`` in a given frame of " "execution will return the *same* mapping object. Changes made through the " @@ -2086,7 +2091,7 @@ msgid "" "returned mapping object." msgstr "" -#: ../../library/functions.rst:1175 +#: ../../library/functions.rst:1177 msgid "" "In an :term:`optimized scope` (including functions, generators, and " "coroutines), each call to ``locals()`` instead returns a fresh dictionary " @@ -2098,7 +2103,7 @@ msgid "" "previously returned dictionaries." msgstr "" -#: ../../library/functions.rst:1184 +#: ../../library/functions.rst:1186 msgid "" "Calling ``locals()`` as part of a comprehension in a function, generator, or " "coroutine is equivalent to calling it in the containing scope, except that " @@ -2107,19 +2112,19 @@ msgid "" "function." msgstr "" -#: ../../library/functions.rst:1190 +#: ../../library/functions.rst:1192 msgid "" "Calling ``locals()`` as part of a generator expression is equivalent to " "calling it in a nested generator function." msgstr "" -#: ../../library/functions.rst:1193 +#: ../../library/functions.rst:1195 msgid "" "The behaviour of ``locals()`` in a comprehension has been updated as " "described in :pep:`709`." msgstr "" -#: ../../library/functions.rst:1197 +#: ../../library/functions.rst:1199 msgid "" "As part of :pep:`667`, the semantics of mutating the mapping objects " "returned from this function are now defined. The behavior in :term:" @@ -2128,7 +2133,7 @@ msgid "" "versions." msgstr "" -#: ../../library/functions.rst:1207 +#: ../../library/functions.rst:1209 msgid "" "Return an iterator that applies *function* to every item of *iterable*, " "yielding the results. If additional *iterables* arguments are passed, " @@ -2146,17 +2151,17 @@ msgstr "" "代物件在其他可疊代物件之前耗盡,則會拋出 :exc:`ValueError`。如果函式的輸入已" "經被編排為引數的元組,請參閱 :func:`itertools.starmap`。" -#: ../../library/functions.rst:1216 +#: ../../library/functions.rst:1218 msgid "Added the *strict* parameter." msgstr "增加了 *strict* 參數。" -#: ../../library/functions.rst:1224 +#: ../../library/functions.rst:1226 msgid "" "Return the largest item in an iterable or the largest of two or more " "arguments." msgstr "回傳 iterable 中最大的元素,或者回傳兩個以上的引數中最大的。" -#: ../../library/functions.rst:1227 +#: ../../library/functions.rst:1229 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The largest item in the iterable is returned. If two or more positional " @@ -2165,7 +2170,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是個 :term:`iterable`,iterable 中最大的元素" "會被回傳。如果提供了兩個或以上的位置引數,則回傳最大的位置引數。" -#: ../../library/functions.rst:1232 ../../library/functions.rst:1270 +#: ../../library/functions.rst:1234 ../../library/functions.rst:1272 msgid "" "There are two optional keyword-only arguments. The *key* argument specifies " "a one-argument ordering function like that used for :meth:`list.sort`. The " @@ -2178,7 +2183,7 @@ msgstr "" "的物件。如果 iterable 為空,並且沒有提供 *default*,則會引發 :exc:" "`ValueError`。" -#: ../../library/functions.rst:1238 +#: ../../library/functions.rst:1240 msgid "" "If multiple items are maximal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2189,15 +2194,15 @@ msgstr "" "``sorted(iterable, key=keyfunc, reverse=True)[0]`` 和 ``heapq.nlargest(1, " "iterable, key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1243 ../../library/functions.rst:1281 +#: ../../library/functions.rst:1245 ../../library/functions.rst:1283 msgid "Added the *default* keyword-only parameter." msgstr "新增 *default* 僅限關鍵字參數。" -#: ../../library/functions.rst:1246 ../../library/functions.rst:1284 +#: ../../library/functions.rst:1248 ../../library/functions.rst:1286 msgid "The *key* can be ``None``." msgstr "*key* 可以為 ``None``。" -#: ../../library/functions.rst:1254 +#: ../../library/functions.rst:1256 msgid "" "Return a \"memory view\" object created from the given argument. See :ref:" "`typememoryview` for more information." @@ -2205,13 +2210,13 @@ msgstr "" "回傳由給定的引數所建立之「memory view(記憶體檢視)」物件。有關詳細資訊,請參" "閱\\ :ref:`typememoryview`。" -#: ../../library/functions.rst:1262 +#: ../../library/functions.rst:1264 msgid "" "Return the smallest item in an iterable or the smallest of two or more " "arguments." msgstr "回傳 iterable 中最小的元素,或者回傳兩個以上的引數中最小的。" -#: ../../library/functions.rst:1265 +#: ../../library/functions.rst:1267 msgid "" "If one positional argument is provided, it should be an :term:`iterable`. " "The smallest item in the iterable is returned. If two or more positional " @@ -2220,7 +2225,7 @@ msgstr "" "如果只提供了一個位置引數,它必須是 :term:`iterable`,iterable 中最小的元素會" "被回傳。如果提供了兩個以上的位置引數,則回傳最小的位置引數。" -#: ../../library/functions.rst:1276 +#: ../../library/functions.rst:1278 msgid "" "If multiple items are minimal, the function returns the first one " "encountered. This is consistent with other sort-stability preserving tools " @@ -2231,7 +2236,7 @@ msgstr "" "``sorted(iterable, key=keyfunc)[0]`` 和 ``heapq.nsmallest(1, iterable, " "key=keyfunc)`` 一致。" -#: ../../library/functions.rst:1291 +#: ../../library/functions.rst:1293 msgid "" "Retrieve the next item from the :term:`iterator` by calling its :meth:" "`~iterator.__next__` method. If *default* is given, it is returned if the " @@ -2241,7 +2246,7 @@ msgstr "" "素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引發 :" "exc:`StopIteration`。" -#: ../../library/functions.rst:1298 +#: ../../library/functions.rst:1300 msgid "" "This is the ultimate base class of all other classes. It has methods that " "are common to all instances of Python classes. When the constructor is " @@ -2252,7 +2257,7 @@ msgstr "" "函式被呼叫時,它會回傳一個新的沒有特徵 (featureless) 的物件。這個建構函式不接" "受任何引數。" -#: ../../library/functions.rst:1305 +#: ../../library/functions.rst:1307 msgid "" ":class:`object` instances do *not* have :attr:`~object.__dict__` attributes, " "so you can't assign arbitrary attributes to an instance of :class:`object`." @@ -2260,7 +2265,7 @@ msgstr "" "由於 :class:`object` 實例\\ *沒有* :attr:`~object.__dict__` 屬性,因此無法將" "任意屬性賦給 :class:`object` 的實例。" -#: ../../library/functions.rst:1312 +#: ../../library/functions.rst:1314 msgid "" "Convert an integer number to an octal string prefixed with \"0o\". The " "result is a valid Python expression. If *integer* is not a Python :class:" @@ -2271,7 +2276,7 @@ msgstr "" "Python 運算式。如果 *integer* 不是 Python 的 :class:`int` 物件,那它需要定" "義 :meth:`~object.__index__` method 回傳一個整數。舉例來說:" -#: ../../library/functions.rst:1322 +#: ../../library/functions.rst:1324 msgid "" "If you want to convert an integer number to an octal string either with the " "prefix \"0o\" or not, you can use either of the following ways." @@ -2279,7 +2284,7 @@ msgstr "" "如果要將整數轉換為八進位制字串,不論是否具備 \"0o\" 前綴,都可以使用下面的方" "法。" -#: ../../library/functions.rst:1339 +#: ../../library/functions.rst:1341 msgid "" "Open *file* and return a corresponding :term:`file object`. If the file " "cannot be opened, an :exc:`OSError` is raised. See :ref:`tut-files` for more " @@ -2289,7 +2294,7 @@ msgstr "" "啟,則引發 :exc:`OSError`。關於使用此函式的更多方法,請參閱\\ :ref:`tut-" "files`。" -#: ../../library/functions.rst:1343 +#: ../../library/functions.rst:1345 msgid "" "*file* is a :term:`path-like object` giving the pathname (absolute or " "relative to the current working directory) of the file to be opened or an " @@ -2302,7 +2307,7 @@ msgstr "" "器 (file descriptor)。(如果有給定檔案描述器,它會隨著回傳的 I/O 物件關閉而關" "閉,除非 *closefd* 被設為 ``False``。)" -#: ../../library/functions.rst:1349 +#: ../../library/functions.rst:1351 msgid "" "*mode* is an optional string that specifies the mode in which the file is " "opened. It defaults to ``'r'`` which means open for reading in text mode. " @@ -2323,71 +2328,71 @@ msgstr "" "getencoding` 來取得目前的本地編碼。(要讀取和寫入原始 bytes,請使用二進位制模" "式且不要指定 *encoding*。)可用的模式有:" -#: ../../library/functions.rst:1366 +#: ../../library/functions.rst:1368 msgid "Character" msgstr "字元" -#: ../../library/functions.rst:1366 +#: ../../library/functions.rst:1368 msgid "Meaning" msgstr "意義" -#: ../../library/functions.rst:1368 +#: ../../library/functions.rst:1370 msgid "``'r'``" msgstr "``'r'``" -#: ../../library/functions.rst:1368 +#: ../../library/functions.rst:1370 msgid "open for reading (default)" msgstr "讀取(預設)" -#: ../../library/functions.rst:1369 +#: ../../library/functions.rst:1371 msgid "``'w'``" msgstr "``'w'``" -#: ../../library/functions.rst:1369 +#: ../../library/functions.rst:1371 msgid "open for writing, truncating the file first" msgstr "寫入,會先清除檔案內容" -#: ../../library/functions.rst:1370 +#: ../../library/functions.rst:1372 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/functions.rst:1370 +#: ../../library/functions.rst:1372 msgid "open for exclusive creation, failing if the file already exists" msgstr "唯一性建立,如果文件已存在則會失敗" -#: ../../library/functions.rst:1371 +#: ../../library/functions.rst:1373 msgid "``'a'``" msgstr "``'a'``" -#: ../../library/functions.rst:1371 +#: ../../library/functions.rst:1373 msgid "open for writing, appending to the end of file if it exists" msgstr "寫入,如果檔案存在則在其末端附加內容" -#: ../../library/functions.rst:1372 +#: ../../library/functions.rst:1374 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/functions.rst:1372 ../../library/functions.rst:1516 +#: ../../library/functions.rst:1374 ../../library/functions.rst:1518 msgid "binary mode" msgstr "二進制模式" -#: ../../library/functions.rst:1373 +#: ../../library/functions.rst:1375 msgid "``'t'``" msgstr "``'t'``" -#: ../../library/functions.rst:1373 +#: ../../library/functions.rst:1375 msgid "text mode (default)" msgstr "文字模式(預設)" -#: ../../library/functions.rst:1374 +#: ../../library/functions.rst:1376 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/functions.rst:1374 +#: ../../library/functions.rst:1376 msgid "open for updating (reading and writing)" msgstr "更新(讀取並寫入)" -#: ../../library/functions.rst:1377 +#: ../../library/functions.rst:1379 msgid "" "The default mode is ``'r'`` (open for reading text, a synonym of ``'rt'``). " "Modes ``'w+'`` and ``'w+b'`` open and truncate the file. Modes ``'r+'`` and " @@ -2397,7 +2402,7 @@ msgstr "" "``'w+b'`` 模式會開啟並清除檔案。``'r+'`` 和 ``'r+b'`` 模式會開啟且保留檔案內" "容。" -#: ../../library/functions.rst:1381 +#: ../../library/functions.rst:1383 msgid "" "As mentioned in the :ref:`io-overview`, Python distinguishes between binary " "and text I/O. Files opened in binary mode (including ``'b'`` in the *mode* " @@ -2413,7 +2418,7 @@ msgstr "" "``'t'``),檔案的內容會以 :class:`str` 回傳,其位元組已經先被解碼,使用的是取" "決於平台的編碼系統或是給定的 *encoding*。" -#: ../../library/functions.rst:1391 +#: ../../library/functions.rst:1393 msgid "" "Python doesn't depend on the underlying operating system's notion of text " "files; all the processing is done by Python itself, and is therefore " @@ -2422,7 +2427,7 @@ msgstr "" "Python 不會使用底層作業系統對於文字檔案的操作概念;所有的處理都是由 Python 獨" "自完成的,因此能獨立於不同平台。" -#: ../../library/functions.rst:1395 +#: ../../library/functions.rst:1397 msgid "" "*buffering* is an optional integer used to set the buffering policy. Pass 0 " "to switch buffering off (only allowed in binary mode), 1 to select line " @@ -2443,7 +2448,7 @@ msgstr "" "``write_through`` 旗標。若未給定 *buffering* 引數,則預設的緩衝策略會運作如" "下:" -#: ../../library/functions.rst:1405 +#: ../../library/functions.rst:1407 msgid "" "Binary files are buffered in fixed-size chunks; the size of the buffer is " "``max(min(blocksize, 8 MiB), DEFAULT_BUFFER_SIZE)`` when the device block " @@ -2454,7 +2459,7 @@ msgstr "" "MiB), DEFAULT_BUFFER_SIZE)``,當裝置區塊大小可用時。在大多數系統上,緩衝區的" "長度通常為 128 KB。" -#: ../../library/functions.rst:1410 +#: ../../library/functions.rst:1412 msgid "" "\"Interactive\" text files (files for which :meth:`~io.IOBase.isatty` " "returns ``True``) use line buffering. Other text files use the policy " @@ -2463,7 +2468,7 @@ msgstr "" "「互動式」文字檔(:meth:`~io.IOBase.isatty` 回傳 ``True`` 的檔案)會使用列緩" "衝。其他文字檔則使用上述的二進制檔案緩衝策略。" -#: ../../library/functions.rst:1414 +#: ../../library/functions.rst:1416 msgid "" "*encoding* is the name of the encoding used to decode or encode the file. " "This should only be used in text mode. The default encoding is platform " @@ -2476,7 +2481,7 @@ msgstr "" "Python 支援的任何 :term:`text encoding`\\ (文字編碼)都是可以使用的。關於支" "援的編碼系統清單,請參閱 :mod:`codecs` module。" -#: ../../library/functions.rst:1420 +#: ../../library/functions.rst:1422 msgid "" "*errors* is an optional string that specifies how encoding and decoding " "errors are to be handled—this cannot be used in binary mode. A variety of " @@ -2489,7 +2494,7 @@ msgstr "" "handlers`\\ 有列出清單),不過任何已註冊到 :func:`codecs.register_error` 的錯" "誤處理程式名稱也都是有效的。標準的名稱包括:" -#: ../../library/functions.rst:1428 +#: ../../library/functions.rst:1430 msgid "" "``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding " "error. The default value of ``None`` has the same effect." @@ -2497,20 +2502,20 @@ msgstr "" "``'strict'`` 如果發生編碼錯誤,則引發 :exc:`ValueError` 例外。預設值 " "``None`` 也有相同的效果。" -#: ../../library/functions.rst:1432 +#: ../../library/functions.rst:1434 msgid "" "``'ignore'`` ignores errors. Note that ignoring encoding errors can lead to " "data loss." msgstr "``'ignore'`` 忽略錯誤。請注意,忽略編碼錯誤可能導致資料遺失。" -#: ../../library/functions.rst:1435 +#: ../../library/functions.rst:1437 msgid "" "``'replace'`` causes a replacement marker (such as ``'?'``) to be inserted " "where there is malformed data." msgstr "" "``'replace'`` 會在格式不正確的資料位置插入一個替換標誌(像是 ``'?'``)。" -#: ../../library/functions.rst:1438 +#: ../../library/functions.rst:1440 msgid "" "``'surrogateescape'`` will represent any incorrect bytes as low surrogate " "code units ranging from U+DC80 to U+DCFF. These surrogate code units will " @@ -2523,7 +2528,7 @@ msgstr "" "被還原回 ``surrogateescape`` 錯誤處理程式當時所處理的那些相同位元組。這對於處" "理未知編碼方式的檔案會很好用。" -#: ../../library/functions.rst:1445 +#: ../../library/functions.rst:1447 msgid "" "``'xmlcharrefreplace'`` is only supported when writing to a file. Characters " "not supported by the encoding are replaced with the appropriate XML " @@ -2532,7 +2537,7 @@ msgstr "" "``'xmlcharrefreplace'`` 僅在寫入檔案時可支援。編碼系統不支援的字元會被替換為" "適當的 XML 字元參考 (character reference) ``&#nnn;``。" -#: ../../library/functions.rst:1449 +#: ../../library/functions.rst:1451 msgid "" "``'backslashreplace'`` replaces malformed data by Python's backslashed " "escape sequences." @@ -2540,7 +2545,7 @@ msgstr "" "``'backslashreplace'`` 會用 Python 的反斜線跳脫序列 (backslashed escape " "sequence) 替換格式不正確的資料。" -#: ../../library/functions.rst:1452 +#: ../../library/functions.rst:1454 msgid "" "``'namereplace'`` (also only supported when writing) replaces unsupported " "characters with ``\\N{...}`` escape sequences." @@ -2548,7 +2553,7 @@ msgstr "" "``'namereplace'``\\ (也僅在寫入時支援)會將不支援的字元替換為 ``\\N{...}`` " "跳脫序列。" -#: ../../library/functions.rst:1460 +#: ../../library/functions.rst:1462 msgid "" "*newline* determines how to parse newline characters from the stream. It can " "be ``None``, ``''``, ``'\\n'``, ``'\\r'``, and ``'\\r\\n'``. It works as " @@ -2557,7 +2562,7 @@ msgstr "" "*newline* 會決定如何剖析資料串流 (stream) 中的換行字元。它可以是 ``None``、" "``''``、``'\\n'``、``'\\r'`` 或 ``'\\r\\n'``。它的運作規則如下:" -#: ../../library/functions.rst:1464 +#: ../../library/functions.rst:1466 msgid "" "When reading input from the stream, if *newline* is ``None``, universal " "newlines mode is enabled. Lines in the input can end in ``'\\n'``, " @@ -2573,7 +2578,7 @@ msgstr "" "傳給呼叫方時,行尾符號不會被轉換。如果它是任何其他有效的值,則輸入資料的行只" "會由給定的字串做結尾,且在回傳給呼叫方時,行尾符號不會被轉換。" -#: ../../library/functions.rst:1472 +#: ../../library/functions.rst:1474 msgid "" "When writing output to the stream, if *newline* is ``None``, any ``'\\n'`` " "characters written are translated to the system default line separator, :" @@ -2586,7 +2591,7 @@ msgstr "" "``''`` 或 ``'\\n'``,則不做任何轉換。如果 *newline* 是任何其他有效的值,則寫" "入的任何 ``'\\n'`` 字元都將轉換為給定的字串。" -#: ../../library/functions.rst:1478 +#: ../../library/functions.rst:1480 msgid "" "If *closefd* is ``False`` and a file descriptor rather than a filename was " "given, the underlying file descriptor will be kept open when the file is " @@ -2597,7 +2602,7 @@ msgstr "" "則當檔案關閉時,底層的檔案描述器會保持開啟狀態。如果有給定一個檔名,則 " "*closefd* 必須是 ``True``\\ (預設值);否則將引發錯誤。" -#: ../../library/functions.rst:1483 +#: ../../library/functions.rst:1485 msgid "" "A custom opener can be used by passing a callable as *opener*. The " "underlying file descriptor for the file object is then obtained by calling " @@ -2610,11 +2615,11 @@ msgstr "" "必須回傳一個開啟的檔案描述器(將 :mod:`os.open` 作為 *opener* 傳入,在功能上" "的結果會相當於傳入 ``None``)。" -#: ../../library/functions.rst:1489 +#: ../../library/functions.rst:1491 msgid "The newly created file is :ref:`non-inheritable `." msgstr "新建立的檔案是\\ :ref:`不可繼承的 `。" -#: ../../library/functions.rst:1491 +#: ../../library/functions.rst:1493 msgid "" "The following example uses the :ref:`dir_fd ` parameter of the :func:" "`os.open` function to open a file relative to a given directory::" @@ -2622,7 +2627,7 @@ msgstr "" "下面的範例使用 :func:`os.open` 函式回傳值當作 :ref:`dir_fd ` 的參數," "從給定的目錄中用相對路徑開啟檔案: ::" -#: ../../library/functions.rst:1494 +#: ../../library/functions.rst:1496 msgid "" ">>> import os\n" ">>> dir_fd = os.open('somedir', os.O_RDONLY)\n" @@ -2644,7 +2649,7 @@ msgstr "" "...\n" ">>> os.close(dir_fd) # don't leak a file descriptor" -#: ../../library/functions.rst:1504 +#: ../../library/functions.rst:1506 msgid "" "The type of :term:`file object` returned by the :func:`open` function " "depends on the mode. When :func:`open` is used to open a file in a text " @@ -2668,7 +2673,7 @@ msgstr "" "BufferedRandom`。當緩衝被停用時,會回傳原始資料串流 :class:`io.FileIO`,它" "是 :class:`io.RawIOBase` 的一個 subclass。" -#: ../../library/functions.rst:1525 +#: ../../library/functions.rst:1527 msgid "" "See also the file handling modules, such as :mod:`fileinput`, :mod:`io` " "(where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:" @@ -2678,7 +2683,7 @@ msgstr "" "`open` 的 module )、:mod:`os`、:mod:`os.path`、:mod:`tempfile` 以及 :mod:" "`shutil`。" -#: ../../library/functions.rst:1529 +#: ../../library/functions.rst:1531 msgid "" "Raises an :ref:`auditing event ` ``open`` with arguments ``path``, " "``mode``, ``flags``." @@ -2686,25 +2691,25 @@ msgstr "" "引發一個附帶引數 ``path``、``mode``、``flags`` 的\\ :ref:`稽核事件 " "` ``open``。" -#: ../../library/functions.rst:1531 +#: ../../library/functions.rst:1533 msgid "" "The ``mode`` and ``flags`` arguments may have been modified or inferred from " "the original call." msgstr "``mode`` 和 ``flags`` 引數可能會被原始的呼叫所修改或推論 (infer)。" -#: ../../library/functions.rst:1536 +#: ../../library/functions.rst:1538 msgid "The *opener* parameter was added." msgstr "新增 *opener* 參數。" -#: ../../library/functions.rst:1537 +#: ../../library/functions.rst:1539 msgid "The ``'x'`` mode was added." msgstr "新增 ``'x'`` 模式。" -#: ../../library/functions.rst:1538 +#: ../../library/functions.rst:1540 msgid ":exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`." msgstr "過去引發的 :exc:`IOError`,現在是 :exc:`OSError` 的別名。" -#: ../../library/functions.rst:1539 +#: ../../library/functions.rst:1541 msgid "" ":exc:`FileExistsError` is now raised if the file opened in exclusive " "creation mode (``'x'``) already exists." @@ -2712,11 +2717,11 @@ msgstr "" "如果檔案已存在但使用了唯一性建立模式 (``'x'``),現在會引發 :exc:" "`FileExistsError`。" -#: ../../library/functions.rst:1544 +#: ../../library/functions.rst:1546 msgid "The file is now non-inheritable." msgstr "檔案在此版本開始是不可繼承的。" -#: ../../library/functions.rst:1548 +#: ../../library/functions.rst:1550 msgid "" "If the system call is interrupted and the signal handler does not raise an " "exception, the function now retries the system call instead of raising an :" @@ -2725,15 +2730,15 @@ msgstr "" "如果系統呼叫被中斷,但訊號處理程式沒有引發例外,此函式現在會重試系統呼叫,而" "不是引發 :exc:`InterruptedError` 例外(原因詳見 :pep:`475`)。" -#: ../../library/functions.rst:1551 +#: ../../library/functions.rst:1553 msgid "The ``'namereplace'`` error handler was added." msgstr "增加了 ``'namereplace'`` 錯誤處理程式。" -#: ../../library/functions.rst:1555 +#: ../../library/functions.rst:1557 msgid "Support added to accept objects implementing :class:`os.PathLike`." msgstr "增加對於實作 :class:`os.PathLike` 物件的支援。" -#: ../../library/functions.rst:1556 +#: ../../library/functions.rst:1558 msgid "" "On Windows, opening a console buffer may return a subclass of :class:`io." "RawIOBase` other than :class:`io.FileIO`." @@ -2741,15 +2746,15 @@ msgstr "" "在 Windows 上,開啟一個控制臺緩衝區可能會回傳 :class:`io.RawIOBase` 的 " "subclass,而不是 :class:`io.FileIO`。" -#: ../../library/functions.rst:1559 +#: ../../library/functions.rst:1561 msgid "The ``'U'`` mode has been removed." msgstr "``'U'`` 模式被移除。" -#: ../../library/functions.rst:1564 +#: ../../library/functions.rst:1566 msgid "Return the ordinal value of a character." msgstr "" -#: ../../library/functions.rst:1566 +#: ../../library/functions.rst:1568 msgid "" "If the argument is a one-character string, return the Unicode code point of " "that character. For example, ``ord('a')`` returns the integer ``97`` and " @@ -2760,14 +2765,14 @@ msgstr "" "整數 ``97``、``ord('€')``\\ (歐元符號)回傳 ``8364``。這是 :func:`chr` 的逆" "函式。" -#: ../../library/functions.rst:1571 +#: ../../library/functions.rst:1573 msgid "" "If the argument is a :class:`bytes` or :class:`bytearray` object of length " "1, return its single byte value. For example, ``ord(b'a')`` returns the " "integer ``97``." msgstr "" -#: ../../library/functions.rst:1578 +#: ../../library/functions.rst:1580 msgid "" "Return *base* to the power *exp*; if *mod* is present, return *base* to the " "power *exp*, modulo *mod* (computed more efficiently than ``pow(base, exp) % " @@ -2778,7 +2783,7 @@ msgstr "" "*mod* 取餘數(比直接呼叫 ``pow(base, exp) % mod`` 計算更高效)。兩個引數形式" "的 ``pow(exp, exp)`` 等價於次方運算子:``base**exp``。" -#: ../../library/functions.rst:1583 +#: ../../library/functions.rst:1585 msgid "" "When arguments are builtin numeric types with mixed operand types, the " "coercion rules for binary arithmetic operators apply. For :class:`int` " @@ -2802,7 +2807,7 @@ msgstr "" "`float` 的負數且指數為整數,則會傳回浮點數結果。例如 ``pow(-9, 2.0)`` 會回傳 " "``81.0``。" -#: ../../library/functions.rst:1595 +#: ../../library/functions.rst:1597 msgid "" "For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must " "also be of integer type and *mod* must be nonzero. If *mod* is present and " @@ -2815,11 +2820,11 @@ msgstr "" "與 *mod* 互質。在這種情況下,會回傳 ``pow(inv_base, -exp, mod)``,其中 " "*inv_base* 是 *base* 對 *mod* 的模倒數 (inverse modulo)。" -#: ../../library/functions.rst:1601 +#: ../../library/functions.rst:1603 msgid "Here's an example of computing an inverse for ``38`` modulo ``97``::" msgstr "以下是一個計算 ``38`` 對 ``97`` 取模倒數的範例: ::" -#: ../../library/functions.rst:1603 +#: ../../library/functions.rst:1605 msgid "" ">>> pow(38, -1, mod=97)\n" "23\n" @@ -2831,7 +2836,7 @@ msgstr "" ">>> 23 * 38 % 97 == 1\n" "True" -#: ../../library/functions.rst:1608 +#: ../../library/functions.rst:1610 msgid "" "For :class:`int` operands, the three-argument form of ``pow`` now allows the " "second argument to be negative, permitting computation of modular inverses." @@ -2839,12 +2844,12 @@ msgstr "" "對於 :class:`int` 運算元,現在 ``pow`` 的三引數形式允許第二個引數為負數,也容" "許模倒數的計算。" -#: ../../library/functions.rst:1613 +#: ../../library/functions.rst:1615 msgid "" "Allow keyword arguments. Formerly, only positional arguments were supported." msgstr "允許關鍵字引數。在此之前只支援位置引數。" -#: ../../library/functions.rst:1620 +#: ../../library/functions.rst:1622 msgid "" "Print *objects* to the text stream *file*, separated by *sep* and followed " "by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as " @@ -2853,7 +2858,7 @@ msgstr "" "將 *objects* 列印到文字資料串流 *file*,用 *sep* 分隔並以 *end* 結尾。如果有" "給定 *sep*、*end*、*file* 和 *flush*,那麼它們必須是關鍵字引數的形式。" -#: ../../library/functions.rst:1624 +#: ../../library/functions.rst:1626 msgid "" "All non-keyword arguments are converted to strings like :func:`str` does and " "written to the stream, separated by *sep* and followed by *end*. Both *sep* " @@ -2866,7 +2871,7 @@ msgstr "" "以是 ``None``,這表示使用預設值。如果沒有給定 *objects*,:func:`print` 就只會" "寫入 *end*。" -#: ../../library/functions.rst:1630 +#: ../../library/functions.rst:1632 msgid "" "The *file* argument must be an object with a ``write(string)`` method; if it " "is not present or ``None``, :data:`sys.stdout` will be used. Since printed " @@ -2878,7 +2883,7 @@ msgstr "" "串,所以 :func:`print` 不能用於二進位模式的檔案物件。對於此類物件,請改用 " "``file.write(...)``。" -#: ../../library/functions.rst:1635 +#: ../../library/functions.rst:1637 msgid "" "Output buffering is usually determined by *file*. However, if *flush* is " "true, the stream is forcibly flushed." @@ -2886,15 +2891,15 @@ msgstr "" "輸出緩衝通常會由 *file* 決定。但是如果 *flush* 為 true,則資料串流會被強制清" "除。" -#: ../../library/functions.rst:1639 +#: ../../library/functions.rst:1641 msgid "Added the *flush* keyword argument." msgstr "增加了 *flush* 關鍵字引數。" -#: ../../library/functions.rst:1645 +#: ../../library/functions.rst:1647 msgid "Return a property attribute." msgstr "回傳 property 屬性。" -#: ../../library/functions.rst:1647 +#: ../../library/functions.rst:1649 msgid "" "*fget* is a function for getting an attribute value. *fset* is a function " "for setting an attribute value. *fdel* is a function for deleting an " @@ -2903,11 +2908,11 @@ msgstr "" "*fget* 是一個用於取得屬性值的函式,*fset* 是一個用於設定屬性值的函式,*fdel* " "是一個用於刪除屬性值的函式,而 *doc* 會為該屬性建立一個說明字串。" -#: ../../library/functions.rst:1651 +#: ../../library/functions.rst:1653 msgid "A typical use is to define a managed attribute ``x``::" msgstr "一個典型的用途是定義一個受管理的屬性 ``x``: ::" -#: ../../library/functions.rst:1653 +#: ../../library/functions.rst:1655 msgid "" "class C:\n" " def __init__(self):\n" @@ -2939,7 +2944,7 @@ msgstr "" "\n" " x = property(getx, setx, delx, \"I'm the 'x' property.\")" -#: ../../library/functions.rst:1668 +#: ../../library/functions.rst:1670 msgid "" "If *c* is an instance of *C*, ``c.x`` will invoke the getter, ``c.x = " "value`` will invoke the setter, and ``del c.x`` the deleter." @@ -2947,7 +2952,7 @@ msgstr "" "如果 *c* 是 *C* 的一個實例,則 ``c.x`` 將會叫用取得器 (getter),``c.x = " "value`` 會呼叫設定器 (setter),而 ``del c.x`` 會叫用刪除器 (deleter)。" -#: ../../library/functions.rst:1671 +#: ../../library/functions.rst:1673 msgid "" "If given, *doc* will be the docstring of the property attribute. Otherwise, " "the property will copy *fget*'s docstring (if it exists). This makes it " @@ -2958,7 +2963,7 @@ msgstr "" "*fget* 的說明字串(如果它存在的話)。這樣一來,就能夠輕鬆地使用 :func:" "`property` 作為\\ :term:`裝飾器 `\\ 來建立唯讀屬性: ::" -#: ../../library/functions.rst:1675 +#: ../../library/functions.rst:1677 msgid "" "class Parrot:\n" " def __init__(self):\n" @@ -2970,14 +2975,14 @@ msgid "" " return self._voltage" msgstr "" -#: ../../library/functions.rst:1684 +#: ../../library/functions.rst:1686 msgid "" "The ``@property`` decorator turns the :meth:`!voltage` method into a " "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" -#: ../../library/functions.rst:1692 +#: ../../library/functions.rst:1694 msgid "" "A property object has ``getter``, ``setter``, and ``deleter`` methods usable " "as decorators that create a copy of the property with the corresponding " @@ -2985,7 +2990,7 @@ msgid "" "with an example:" msgstr "" -#: ../../library/functions.rst:1697 +#: ../../library/functions.rst:1699 msgid "" "class C:\n" " def __init__(self):\n" @@ -3021,36 +3026,36 @@ msgstr "" " def x(self):\n" " del self._x" -#: ../../library/functions.rst:1716 +#: ../../library/functions.rst:1718 msgid "" "This code is exactly equivalent to the first example. Be sure to give the " "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" -#: ../../library/functions.rst:1720 +#: ../../library/functions.rst:1722 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" -#: ../../library/functions.rst:1723 +#: ../../library/functions.rst:1725 msgid "The docstrings of property objects are now writeable." msgstr "" -#: ../../library/functions.rst:1728 +#: ../../library/functions.rst:1730 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." msgstr "" -#: ../../library/functions.rst:1739 +#: ../../library/functions.rst:1741 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:1745 +#: ../../library/functions.rst:1747 msgid "" "Return a string containing a printable representation of an object. For " "many types, this function makes an attempt to return a string that would " @@ -3063,11 +3068,11 @@ msgid "" "raise :exc:`RuntimeError`." msgstr "" -#: ../../library/functions.rst:1756 +#: ../../library/functions.rst:1758 msgid "This class has a custom representation that can be evaluated::" msgstr "" -#: ../../library/functions.rst:1758 +#: ../../library/functions.rst:1760 msgid "" "class Person:\n" " def __init__(self, name, age):\n" @@ -3085,7 +3090,7 @@ msgstr "" " def __repr__(self):\n" " return f\"Person('{self.name}', {self.age})\"" -#: ../../library/functions.rst:1769 +#: ../../library/functions.rst:1771 msgid "" "Return a reverse :term:`iterator`. The argument must be an object which has " "a :meth:`~object.__reversed__` method or supports the sequence protocol " @@ -3093,14 +3098,14 @@ msgid "" "method with integer arguments starting at ``0``)." msgstr "" -#: ../../library/functions.rst:1777 +#: ../../library/functions.rst:1779 msgid "" "Return *number* rounded to *ndigits* precision after the decimal point. If " "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" -#: ../../library/functions.rst:1781 +#: ../../library/functions.rst:1783 msgid "" "For the built-in types supporting :func:`round`, values are rounded to the " "closest multiple of 10 to the power minus *ndigits*; if two multiples are " @@ -3111,13 +3116,13 @@ msgid "" "``None``. Otherwise, the return value has the same type as *number*." msgstr "" -#: ../../library/functions.rst:1790 +#: ../../library/functions.rst:1792 msgid "" "For a general Python object ``number``, ``round`` delegates to ``number." "__round__``." msgstr "" -#: ../../library/functions.rst:1795 +#: ../../library/functions.rst:1797 msgid "" "The behavior of :func:`round` for floats can be surprising: for example, " "``round(2.675, 2)`` gives ``2.67`` instead of the expected ``2.68``. This is " @@ -3126,21 +3131,21 @@ msgid "" "information." msgstr "" -#: ../../library/functions.rst:1806 +#: ../../library/functions.rst:1808 msgid "" "Return a new :class:`set` object, optionally with elements taken from " "*iterable*. ``set`` is a built-in class. See :class:`set` and :ref:`types-" "set` for documentation about this class." msgstr "" -#: ../../library/functions.rst:1810 +#: ../../library/functions.rst:1812 msgid "" "For other containers see the built-in :class:`frozenset`, :class:`list`, :" "class:`tuple`, and :class:`dict` classes, as well as the :mod:`collections` " "module." msgstr "" -#: ../../library/functions.rst:1817 +#: ../../library/functions.rst:1819 msgid "" "This is the counterpart of :func:`getattr`. The arguments are an object, a " "string, and an arbitrary value. The string may name an existing attribute " @@ -3149,7 +3154,7 @@ msgid "" "is equivalent to ``x.foobar = 123``." msgstr "" -#: ../../library/functions.rst:1823 +#: ../../library/functions.rst:1825 msgid "" "*name* need not be a Python identifier as defined in :ref:`identifiers` " "unless the object chooses to enforce that, for example in a custom :meth:" @@ -3158,21 +3163,21 @@ msgid "" "notation, but is accessible through :func:`getattr` etc.." msgstr "" -#: ../../library/functions.rst:1831 +#: ../../library/functions.rst:1833 msgid "" "Since :ref:`private name mangling ` happens at " "compilation time, one must manually mangle a private attribute's (attributes " "with two leading underscores) name in order to set it with :func:`setattr`." msgstr "" -#: ../../library/functions.rst:1840 +#: ../../library/functions.rst:1842 msgid "" "Return a :term:`slice` object representing the set of indices specified by " "``range(start, stop, step)``. The *start* and *step* arguments default to " "``None``." msgstr "" -#: ../../library/functions.rst:1844 +#: ../../library/functions.rst:1846 msgid "" "Slice objects have read-only data attributes :attr:`!start`, :attr:`!stop`, " "and :attr:`!step` which merely return the argument values (or their " @@ -3180,48 +3185,48 @@ msgid "" "by NumPy and other third-party packages." msgstr "" -#: ../../library/functions.rst:1853 +#: ../../library/functions.rst:1855 msgid "" "Slice objects are also generated when extended indexing syntax is used. For " "example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:" "`itertools.islice` for an alternate version that returns an :term:`iterator`." msgstr "" -#: ../../library/functions.rst:1858 +#: ../../library/functions.rst:1860 msgid "" "Slice objects are now :term:`hashable` (provided :attr:`~slice.start`, :attr:" "`~slice.stop`, and :attr:`~slice.step` are hashable)." msgstr "" -#: ../../library/functions.rst:1864 +#: ../../library/functions.rst:1866 msgid "Return a new sorted list from the items in *iterable*." msgstr "" -#: ../../library/functions.rst:1866 +#: ../../library/functions.rst:1868 msgid "" "Has two optional arguments which must be specified as keyword arguments." msgstr "有兩個選擇性引數,只能使用關鍵字引數來指定。" -#: ../../library/functions.rst:1868 +#: ../../library/functions.rst:1870 msgid "" "*key* specifies a function of one argument that is used to extract a " "comparison key from each element in *iterable* (for example, ``key=str." "lower``). The default value is ``None`` (compare the elements directly)." msgstr "" -#: ../../library/functions.rst:1872 +#: ../../library/functions.rst:1874 msgid "" "*reverse* is a boolean value. If set to ``True``, then the list elements " "are sorted as if each comparison were reversed." msgstr "" -#: ../../library/functions.rst:1875 +#: ../../library/functions.rst:1877 msgid "" "Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a " "*key* function." msgstr "" -#: ../../library/functions.rst:1878 +#: ../../library/functions.rst:1880 msgid "" "The built-in :func:`sorted` function is guaranteed to be stable. A sort is " "stable if it guarantees not to change the relative order of elements that " @@ -3229,7 +3234,7 @@ msgid "" "example, sort by department, then by salary grade)." msgstr "" -#: ../../library/functions.rst:1883 +#: ../../library/functions.rst:1885 msgid "" "The sort algorithm uses only ``<`` comparisons between items. While " "defining an :meth:`~object.__lt__` method will suffice for sorting, :PEP:`8` " @@ -3241,22 +3246,22 @@ msgid "" "method." msgstr "" -#: ../../library/functions.rst:1892 +#: ../../library/functions.rst:1894 msgid "" "For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`." msgstr "" -#: ../../library/functions.rst:1896 +#: ../../library/functions.rst:1898 msgid "Transform a method into a static method." msgstr "" -#: ../../library/functions.rst:1898 +#: ../../library/functions.rst:1900 msgid "" "A static method does not receive an implicit first argument. To declare a " "static method, use this idiom::" msgstr "" -#: ../../library/functions.rst:1901 +#: ../../library/functions.rst:1903 msgid "" "class C:\n" " @staticmethod\n" @@ -3266,7 +3271,7 @@ msgstr "" " @staticmethod\n" " def f(arg1, arg2, argN): ..." -#: ../../library/functions.rst:1905 +#: ../../library/functions.rst:1907 msgid "" "The ``@staticmethod`` form is a function :term:`decorator` -- see :ref:" "`function` for details." @@ -3274,7 +3279,7 @@ msgstr "" "``@staticmethod`` 語法是一個函式 :term:`decorator` - 參見 :ref:`function` 中" "的詳細介紹。" -#: ../../library/functions.rst:1908 +#: ../../library/functions.rst:1910 msgid "" "A static method can be called either on the class (such as ``C.f()``) or on " "an instance (such as ``C().f()``). Moreover, the static method :term:" @@ -3282,14 +3287,14 @@ msgid "" "(such as ``f()``)." msgstr "" -#: ../../library/functions.rst:1913 +#: ../../library/functions.rst:1915 msgid "" "Static methods in Python are similar to those found in Java or C++. Also, " "see :func:`classmethod` for a variant that is useful for creating alternate " "class constructors." msgstr "" -#: ../../library/functions.rst:1917 +#: ../../library/functions.rst:1919 msgid "" "Like all decorators, it is also possible to call ``staticmethod`` as a " "regular function and do something with its result. This is needed in some " @@ -3298,7 +3303,7 @@ msgid "" "cases, use this idiom::" msgstr "" -#: ../../library/functions.rst:1923 +#: ../../library/functions.rst:1925 msgid "" "def regular_function():\n" " ...\n" @@ -3312,11 +3317,11 @@ msgstr "" "class C:\n" " method = staticmethod(regular_function)" -#: ../../library/functions.rst:1929 +#: ../../library/functions.rst:1931 msgid "For more information on static methods, see :ref:`types`." msgstr "關於 static method 的更多資訊,請參考 :ref:`types`。" -#: ../../library/functions.rst:1931 +#: ../../library/functions.rst:1933 msgid "" "Static methods now inherit the method attributes (:attr:`~function." "__module__`, :attr:`~function.__name__`, :attr:`~function.__qualname__`, :" @@ -3328,25 +3333,25 @@ msgstr "" "__doc__` 和 :attr:`~function.__annotations__`),並擁有一個新的 " "``__wrapped__`` 屬性,且為如一般函式的可呼叫物件。" -#: ../../library/functions.rst:1949 +#: ../../library/functions.rst:1951 msgid "" "Return a :class:`str` version of *object*. See :func:`str` for details." msgstr "" -#: ../../library/functions.rst:1951 +#: ../../library/functions.rst:1953 msgid "" "``str`` is the built-in string :term:`class`. For general information about " "strings, see :ref:`textseq`." msgstr "" -#: ../../library/functions.rst:1957 +#: ../../library/functions.rst:1959 msgid "" "Sums *start* and the items of an *iterable* from left to right and returns " "the total. The *iterable*'s items are normally numbers, and the start value " "is not allowed to be a string." msgstr "" -#: ../../library/functions.rst:1961 +#: ../../library/functions.rst:1963 msgid "" "For some use cases, there are good alternatives to :func:`sum`. The " "preferred, fast way to concatenate a sequence of strings is by calling ``''." @@ -3355,43 +3360,43 @@ msgid "" "using :func:`itertools.chain`." msgstr "" -#: ../../library/functions.rst:1967 +#: ../../library/functions.rst:1969 msgid "The *start* parameter can be specified as a keyword argument." msgstr "*start* 參數可被指定為關鍵字引數。" -#: ../../library/functions.rst:1970 +#: ../../library/functions.rst:1972 msgid "" "Summation of floats switched to an algorithm that gives higher accuracy and " "better commutativity on most builds." msgstr "" -#: ../../library/functions.rst:1973 +#: ../../library/functions.rst:1975 msgid "" "Added specialization for summation of complexes, using same algorithm as for " "summation of floats." msgstr "" -#: ../../library/functions.rst:1981 +#: ../../library/functions.rst:1983 msgid "" "Return a proxy object that delegates method calls to a parent or sibling " "class of *type*. This is useful for accessing inherited methods that have " "been overridden in a class." msgstr "" -#: ../../library/functions.rst:1985 +#: ../../library/functions.rst:1987 msgid "" "The *object_or_type* determines the :term:`method resolution order` to be " "searched. The search starts from the class right after the *type*." msgstr "" -#: ../../library/functions.rst:1989 +#: ../../library/functions.rst:1991 msgid "" "For example, if :attr:`~type.__mro__` of *object_or_type* is ``D -> B -> C -" "> A -> object`` and the value of *type* is ``B``, then :func:`super` " "searches ``C -> A -> object``." msgstr "" -#: ../../library/functions.rst:1993 +#: ../../library/functions.rst:1995 msgid "" "The :attr:`~type.__mro__` attribute of the class corresponding to " "*object_or_type* lists the method resolution search order used by both :func:" @@ -3399,7 +3404,7 @@ msgid "" "whenever the inheritance hierarchy is updated." msgstr "" -#: ../../library/functions.rst:1998 +#: ../../library/functions.rst:2000 msgid "" "If the second argument is omitted, the super object returned is unbound. If " "the second argument is an object, ``isinstance(obj, type)`` must be true. " @@ -3407,7 +3412,7 @@ msgid "" "(this is useful for classmethods)." msgstr "" -#: ../../library/functions.rst:2003 +#: ../../library/functions.rst:2005 msgid "" "When called directly within an ordinary method of a class, both arguments " "may be omitted (\"zero-argument :func:`!super`\"). In this case, *type* will " @@ -3417,7 +3422,7 @@ msgid "" "including generator expressions, which implicitly create nested functions.)" msgstr "" -#: ../../library/functions.rst:2010 +#: ../../library/functions.rst:2012 msgid "" "There are two typical use cases for *super*. In a class hierarchy with " "single inheritance, *super* can be used to refer to parent classes without " @@ -3425,7 +3430,7 @@ msgid "" "closely parallels the use of *super* in other programming languages." msgstr "" -#: ../../library/functions.rst:2015 +#: ../../library/functions.rst:2017 msgid "" "The second use case is to support cooperative multiple inheritance in a " "dynamic execution environment. This use case is unique to Python and is not " @@ -3438,11 +3443,11 @@ msgid "" "classes that are unknown prior to runtime)." msgstr "" -#: ../../library/functions.rst:2025 +#: ../../library/functions.rst:2027 msgid "For both use cases, a typical superclass call looks like this::" msgstr "" -#: ../../library/functions.rst:2027 +#: ../../library/functions.rst:2029 msgid "" "class C(B):\n" " def method(self, arg):\n" @@ -3450,14 +3455,14 @@ msgid "" " # super(C, self).method(arg)" msgstr "" -#: ../../library/functions.rst:2032 +#: ../../library/functions.rst:2034 msgid "" "In addition to method lookups, :func:`super` also works for attribute " "lookups. One possible use case for this is calling :term:`descriptors " "` in a parent or sibling class." msgstr "" -#: ../../library/functions.rst:2036 +#: ../../library/functions.rst:2038 msgid "" "Note that :func:`super` is implemented as part of the binding process for " "explicit dotted attribute lookups such as ``super().__getitem__(name)``. It " @@ -3467,7 +3472,7 @@ msgid "" "using statements or operators such as ``super()[name]``." msgstr "" -#: ../../library/functions.rst:2044 +#: ../../library/functions.rst:2046 msgid "" "Also note that, aside from the zero argument form, :func:`super` is not " "limited to use inside methods. The two argument form specifies the " @@ -3477,39 +3482,39 @@ msgid "" "accessing the current instance for ordinary methods." msgstr "" -#: ../../library/functions.rst:2051 +#: ../../library/functions.rst:2053 msgid "" "For practical suggestions on how to design cooperative classes using :func:" "`super`, see `guide to using super() `_." msgstr "" -#: ../../library/functions.rst:2055 +#: ../../library/functions.rst:2057 msgid "" ":class:`super` objects are now :mod:`pickleable ` and :mod:" "`copyable `." msgstr "" -#: ../../library/functions.rst:2064 +#: ../../library/functions.rst:2066 msgid "" "Rather than being a function, :class:`tuple` is actually an immutable " "sequence type, as documented in :ref:`typesseq-tuple` and :ref:`typesseq`." msgstr "" -#: ../../library/functions.rst:2073 +#: ../../library/functions.rst:2075 msgid "" "With one argument, return the type of an *object*. The return value is a " "type object and generally the same object as returned by :attr:`object." "__class__`." msgstr "" -#: ../../library/functions.rst:2077 +#: ../../library/functions.rst:2079 msgid "" "The :func:`isinstance` built-in function is recommended for testing the type " "of an object, because it takes subclasses into account." msgstr "" -#: ../../library/functions.rst:2080 +#: ../../library/functions.rst:2082 msgid "" "With three arguments, return a new type object. This is essentially a " "dynamic form of the :keyword:`class` statement. The *name* string is the " @@ -3522,21 +3527,21 @@ msgid "" "type` objects:" msgstr "" -#: ../../library/functions.rst:2095 +#: ../../library/functions.rst:2097 msgid "See also:" msgstr "另請參閱:" -#: ../../library/functions.rst:2097 +#: ../../library/functions.rst:2099 msgid "" ":ref:`Documentation on attributes and methods on classes `." msgstr "" -#: ../../library/functions.rst:2098 +#: ../../library/functions.rst:2100 msgid ":ref:`bltin-type-objects`" msgstr ":ref:`bltin-type-objects`" -#: ../../library/functions.rst:2100 +#: ../../library/functions.rst:2102 msgid "" "Keyword arguments provided to the three argument form are passed to the " "appropriate metaclass machinery (usually :meth:`~object.__init_subclass__`) " @@ -3544,23 +3549,23 @@ msgid "" "would." msgstr "" -#: ../../library/functions.rst:2105 +#: ../../library/functions.rst:2107 msgid "See also :ref:`class-customization`." msgstr "另請參閱 :ref:`class-customization`。" -#: ../../library/functions.rst:2107 +#: ../../library/functions.rst:2109 msgid "" "Subclasses of :class:`!type` which don't override ``type.__new__`` may no " "longer use the one-argument form to get the type of an object." msgstr "" -#: ../../library/functions.rst:2114 +#: ../../library/functions.rst:2116 msgid "" "Return the :attr:`~object.__dict__` attribute for a module, class, instance, " "or any other object with a :attr:`!__dict__` attribute." msgstr "" -#: ../../library/functions.rst:2117 +#: ../../library/functions.rst:2119 msgid "" "Objects such as modules and instances have an updateable :attr:`~object." "__dict__` attribute; however, other objects may have write restrictions on " @@ -3568,34 +3573,34 @@ msgid "" "MappingProxyType` to prevent direct dictionary updates)." msgstr "" -#: ../../library/functions.rst:2122 +#: ../../library/functions.rst:2124 msgid "Without an argument, :func:`vars` acts like :func:`locals`." msgstr "" -#: ../../library/functions.rst:2124 +#: ../../library/functions.rst:2126 msgid "" "A :exc:`TypeError` exception is raised if an object is specified but it " "doesn't have a :attr:`~object.__dict__` attribute (for example, if its class " "defines the :attr:`~object.__slots__` attribute)." msgstr "" -#: ../../library/functions.rst:2130 +#: ../../library/functions.rst:2132 msgid "" "The result of calling this function without an argument has been updated as " "described for the :func:`locals` builtin." msgstr "" -#: ../../library/functions.rst:2136 +#: ../../library/functions.rst:2138 msgid "" "Iterate over several iterables in parallel, producing tuples with an item " "from each one." msgstr "" -#: ../../library/functions.rst:2139 +#: ../../library/functions.rst:2141 msgid "Example::" msgstr "例如: ::" -#: ../../library/functions.rst:2141 +#: ../../library/functions.rst:2143 msgid "" ">>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):\n" "... print(item)\n" @@ -3611,27 +3616,27 @@ msgstr "" "(2, 'spice')\n" "(3, 'everything nice')" -#: ../../library/functions.rst:2148 +#: ../../library/functions.rst:2150 msgid "" "More formally: :func:`zip` returns an iterator of tuples, where the *i*-th " "tuple contains the *i*-th element from each of the argument iterables." msgstr "" -#: ../../library/functions.rst:2151 +#: ../../library/functions.rst:2153 msgid "" "Another way to think of :func:`zip` is that it turns rows into columns, and " "columns into rows. This is similar to `transposing a matrix `_." msgstr "" -#: ../../library/functions.rst:2155 +#: ../../library/functions.rst:2157 msgid "" ":func:`zip` is lazy: The elements won't be processed until the iterable is " "iterated on, e.g. by a :keyword:`!for` loop or by wrapping in a :class:" "`list`." msgstr "" -#: ../../library/functions.rst:2159 +#: ../../library/functions.rst:2161 msgid "" "One thing to consider is that the iterables passed to :func:`zip` could have " "different lengths; sometimes by design, and sometimes because of a bug in " @@ -3639,14 +3644,14 @@ msgid "" "approaches to dealing with this issue:" msgstr "" -#: ../../library/functions.rst:2164 +#: ../../library/functions.rst:2166 msgid "" "By default, :func:`zip` stops when the shortest iterable is exhausted. It " "will ignore the remaining items in the longer iterables, cutting off the " "result to the length of the shortest iterable::" msgstr "" -#: ../../library/functions.rst:2168 +#: ../../library/functions.rst:2170 msgid "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" @@ -3654,14 +3659,14 @@ msgstr "" ">>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))\n" "[(0, 'fee'), (1, 'fi'), (2, 'fo')]" -#: ../../library/functions.rst:2171 +#: ../../library/functions.rst:2173 msgid "" ":func:`zip` is often used in cases where the iterables are assumed to be of " "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" -#: ../../library/functions.rst:2175 +#: ../../library/functions.rst:2177 msgid "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" @@ -3669,37 +3674,37 @@ msgstr "" ">>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))\n" "[('a', 1), ('b', 2), ('c', 3)]" -#: ../../library/functions.rst:2178 +#: ../../library/functions.rst:2180 msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" -#: ../../library/functions.rst:2196 +#: ../../library/functions.rst:2198 msgid "" "Without the ``strict=True`` argument, any bug that results in iterables of " "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" -#: ../../library/functions.rst:2200 +#: ../../library/functions.rst:2202 msgid "" "Shorter iterables can be padded with a constant value to make all the " "iterables have the same length. This is done by :func:`itertools." "zip_longest`." msgstr "" -#: ../../library/functions.rst:2204 +#: ../../library/functions.rst:2206 msgid "" "Edge cases: With a single iterable argument, :func:`zip` returns an iterator " "of 1-tuples. With no arguments, it returns an empty iterator." msgstr "" -#: ../../library/functions.rst:2207 +#: ../../library/functions.rst:2209 msgid "Tips and tricks:" msgstr "" -#: ../../library/functions.rst:2209 +#: ../../library/functions.rst:2211 msgid "" "The left-to-right evaluation order of the iterables is guaranteed. This " "makes possible an idiom for clustering a data series into n-length groups " @@ -3708,13 +3713,13 @@ msgid "" "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" -#: ../../library/functions.rst:2215 +#: ../../library/functions.rst:2217 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" msgstr "" -#: ../../library/functions.rst:2218 +#: ../../library/functions.rst:2220 msgid "" ">>> x = [1, 2, 3]\n" ">>> y = [4, 5, 6]\n" @@ -3732,17 +3737,17 @@ msgstr "" ">>> x == list(x2) and y == list(y2)\n" "True" -#: ../../library/functions.rst:2226 +#: ../../library/functions.rst:2228 msgid "Added the ``strict`` argument." msgstr "增加了 ``strict`` 引數。" -#: ../../library/functions.rst:2238 +#: ../../library/functions.rst:2240 msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2241 +#: ../../library/functions.rst:2243 msgid "" "This function is invoked by the :keyword:`import` statement. It can be " "replaced (by importing the :mod:`builtins` module and assigning to " @@ -3754,7 +3759,7 @@ msgid "" "discouraged in favor of :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2250 +#: ../../library/functions.rst:2252 msgid "" "The function imports the module *name*, potentially using the given " "*globals* and *locals* to determine how to interpret the name in a package " @@ -3764,7 +3769,7 @@ msgid "" "determine the package context of the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2257 +#: ../../library/functions.rst:2259 msgid "" "*level* specifies whether to use absolute or relative imports. ``0`` (the " "default) means only perform absolute imports. Positive values for *level* " @@ -3773,7 +3778,7 @@ msgid "" "details)." msgstr "" -#: ../../library/functions.rst:2263 +#: ../../library/functions.rst:2265 msgid "" "When the *name* variable is of the form ``package.module``, normally, the " "top-level package (the name up till the first dot) is returned, *not* the " @@ -3781,37 +3786,37 @@ msgid "" "given, the module named by *name* is returned." msgstr "" -#: ../../library/functions.rst:2268 +#: ../../library/functions.rst:2270 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" msgstr "" -#: ../../library/functions.rst:2271 +#: ../../library/functions.rst:2273 msgid "spam = __import__('spam', globals(), locals(), [], 0)" msgstr "spam = __import__('spam', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2273 +#: ../../library/functions.rst:2275 msgid "The statement ``import spam.ham`` results in this call::" msgstr "" -#: ../../library/functions.rst:2275 +#: ../../library/functions.rst:2277 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" msgstr "spam = __import__('spam.ham', globals(), locals(), [], 0)" -#: ../../library/functions.rst:2277 +#: ../../library/functions.rst:2279 msgid "" "Note how :func:`__import__` returns the toplevel module here because this is " "the object that is bound to a name by the :keyword:`import` statement." msgstr "" -#: ../../library/functions.rst:2280 +#: ../../library/functions.rst:2282 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" msgstr "" -#: ../../library/functions.rst:2283 +#: ../../library/functions.rst:2285 msgid "" "_temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)\n" "eggs = _temp.eggs\n" @@ -3821,36 +3826,36 @@ msgstr "" "eggs = _temp.eggs\n" "saus = _temp.sausage" -#: ../../library/functions.rst:2287 +#: ../../library/functions.rst:2289 msgid "" "Here, the ``spam.ham`` module is returned from :func:`__import__`. From " "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" -#: ../../library/functions.rst:2291 +#: ../../library/functions.rst:2293 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" -#: ../../library/functions.rst:2294 +#: ../../library/functions.rst:2296 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." msgstr "" -#: ../../library/functions.rst:2298 +#: ../../library/functions.rst:2300 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" -#: ../../library/functions.rst:2303 +#: ../../library/functions.rst:2305 msgid "Footnotes" msgstr "註解" -#: ../../library/functions.rst:2304 +#: ../../library/functions.rst:2306 msgid "" "Note that the parser only accepts the Unix-style end of line convention. If " "you are reading the code from a file, make sure to use newline conversion " @@ -3859,110 +3864,110 @@ msgstr "" "剖析器只接受 Unix 風格的行結束符。如果你從檔案中讀取程式碼,請確保用換行符號" "轉換模式轉換 Windows 或 Mac 風格的換行符號。" -#: ../../library/functions.rst:154 +#: ../../library/functions.rst:156 msgid "Boolean" msgstr "Boolean(布林值)" -#: ../../library/functions.rst:154 ../../library/functions.rst:2071 +#: ../../library/functions.rst:156 ../../library/functions.rst:2073 msgid "type" msgstr "type(型別)" -#: ../../library/functions.rst:652 +#: ../../library/functions.rst:654 msgid "built-in function" msgstr "built-in function(內建函式)" -#: ../../library/functions.rst:652 +#: ../../library/functions.rst:654 msgid "exec" msgstr "exec" -#: ../../library/functions.rst:750 +#: ../../library/functions.rst:752 msgid "NaN" msgstr "NaN" -#: ../../library/functions.rst:750 +#: ../../library/functions.rst:752 msgid "Infinity" msgstr "Infinity(無窮)" -#: ../../library/functions.rst:820 +#: ../../library/functions.rst:822 msgid "__format__" msgstr "__format__" -#: ../../library/functions.rst:820 ../../library/functions.rst:1939 +#: ../../library/functions.rst:822 ../../library/functions.rst:1941 msgid "string" msgstr "string(字串)" -#: ../../library/functions.rst:820 +#: ../../library/functions.rst:822 msgid "format() (built-in function)" msgstr "format()(內建函式)" -#: ../../library/functions.rst:1334 +#: ../../library/functions.rst:1336 msgid "file object" msgstr "file object(檔案物件)" -#: ../../library/functions.rst:1334 ../../library/functions.rst:1455 +#: ../../library/functions.rst:1336 ../../library/functions.rst:1457 msgid "open() built-in function" msgstr "open() 內建函式" -#: ../../library/functions.rst:1362 +#: ../../library/functions.rst:1364 msgid "file" msgstr "file(檔案)" -#: ../../library/functions.rst:1362 +#: ../../library/functions.rst:1364 msgid "modes" msgstr "modes(模式)" -#: ../../library/functions.rst:1455 +#: ../../library/functions.rst:1457 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1518 msgid "line-buffered I/O" msgstr "line-buffered I/O(行緩衝 I/O)" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1518 msgid "unbuffered I/O" msgstr "unbuffered I/O(非緩衝 I/O)" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1518 msgid "buffer size, I/O" msgstr "buffer size, I/O(緩衝區大小、I/O)" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1518 msgid "I/O control" msgstr "I/O control(I/O 控制)" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1518 msgid "buffering" msgstr "buffering(緩衝)" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1518 msgid "text mode" msgstr "text mode(文字模式)" -#: ../../library/functions.rst:1516 ../../library/functions.rst:2232 +#: ../../library/functions.rst:1518 ../../library/functions.rst:2234 msgid "module" msgstr "module(模組)" -#: ../../library/functions.rst:1516 +#: ../../library/functions.rst:1518 msgid "sys" msgstr "sys" -#: ../../library/functions.rst:1939 +#: ../../library/functions.rst:1941 msgid "str() (built-in function)" msgstr "str() (內建函式)" -#: ../../library/functions.rst:2071 +#: ../../library/functions.rst:2073 msgid "object" msgstr "object(物件)" -#: ../../library/functions.rst:2232 +#: ../../library/functions.rst:2234 msgid "statement" msgstr "statement(陳述式)" -#: ../../library/functions.rst:2232 +#: ../../library/functions.rst:2234 msgid "import" msgstr "import(引入)" -#: ../../library/functions.rst:2232 +#: ../../library/functions.rst:2234 msgid "builtins" msgstr "builtins(內建)" From c95e1e6ac800f6e52be9685a909b330258f1e05f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 13 Jan 2026 00:14:42 +0000 Subject: [PATCH 2/3] sync with cpython 110a77bf --- library/itertools.po | 664 ++++++----- library/stdtypes.po | 2507 ++++++++++++++++++++++-------------------- 2 files changed, 1731 insertions(+), 1440 deletions(-) diff --git a/library/itertools.po b/library/itertools.po index 1cb3a5deda3..47e5e52c6a2 100644 --- a/library/itertools.po +++ b/library/itertools.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-12 00:16+0000\n" +"POT-Creation-Date: 2026-01-13 00:13+0000\n" "PO-Revision-Date: 2024-08-16 15:01+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1772,10 +1772,11 @@ msgstr "" "``reversed()`` 和 ``enumerate()``)一同使用的模式。" #: ../../library/itertools.rst:820 +#, fuzzy msgid "" "A secondary purpose of the recipes is to serve as an incubator. The " "``accumulate()``, ``compress()``, and ``pairwise()`` itertools started out " -"as recipes. Currently, the ``sliding_window()``, ``iter_index()``, and " +"as recipes. Currently, the ``sliding_window()``, ``derangements()``, and " "``sieve()`` recipes are being tested to see whether they prove their worth." msgstr "" "應用技巧的次要目的是作為 itertools 的孵化器。``accumulate()``, " @@ -1816,11 +1817,16 @@ msgstr "" #: ../../library/itertools.rst:839 #, fuzzy msgid "" +"from itertools import (accumulate, batched, chain, combinations, compress,\n" +" count, cycle, filterfalse, groupby, islice, permutations, product,\n" +" repeat, starmap, tee, zip_longest)\n" "from collections import Counter, deque\n" "from contextlib import suppress\n" "from functools import reduce\n" -"from math import comb, prod, sumprod, isqrt\n" -"from operator import is_not, itemgetter, getitem, mul, neg\n" +"from math import comb, isqrt, prod, sumprod\n" +"from operator import getitem, is_not, itemgetter, mul, neg\n" +"\n" +"# ==== Basic one liners ====\n" "\n" "def take(n, iterable):\n" " \"Return first n items of the iterable as a list.\"\n" @@ -1879,8 +1885,8 @@ msgid "" "def first_true(iterable, default=False, predicate=None):\n" " \"Returns the first true value or the *default* if there is no true " "value.\"\n" -" # first_true([a,b,c], x) → a or b or c or x\n" -" # first_true([a,b], x, f) → a if f(a) else b if f(b) else x\n" +" # first_true([a, b, c], x) → a or b or c or x\n" +" # first_true([a, b], x, f) → a if f(a) else b if f(b) else x\n" " return next(filter(predicate, iterable), default)\n" "\n" "def all_equal(iterable, key=None):\n" @@ -1888,6 +1894,8 @@ msgid "" " # all_equal('4٤௪౪໔', key=int) → True\n" " return len(take(2, groupby(iterable, key))) <= 1\n" "\n" +"# ==== Data pipelines ====\n" +"\n" "def unique_justseen(iterable, key=None):\n" " \"Yield unique elements, preserving order. Remember only the element " "just seen.\"\n" @@ -1922,7 +1930,7 @@ msgid "" "\n" "def sliding_window(iterable, n):\n" " \"Collect data into overlapping fixed-length chunks or blocks.\"\n" -" # sliding_window('ABCDEFG', 4) → ABCD BCDE CDEF DEFG\n" +" # sliding_window('ABCDEFG', 3) → ABC BCD CDE DEF EFG\n" " iterator = iter(iterable)\n" " window = deque(islice(iterator, n - 1), maxlen=n)\n" " for x in iterator:\n" @@ -1931,7 +1939,7 @@ msgid "" "\n" "def grouper(iterable, n, *, incomplete='fill', fillvalue=None):\n" " \"Collect data into non-overlapping fixed-length chunks or blocks.\"\n" -" # grouper('ABCDEFG', 3, fillvalue='x') → ABC DEF Gxx\n" +" # grouper('ABCDEFG', 3, fillvalue='x') → ABC DEF Gxx\n" " # grouper('ABCDEFG', 3, incomplete='strict') → ABC DEF ValueError\n" " # grouper('ABCDEFG', 3, incomplete='ignore') → ABC DEF\n" " iterators = [iter(iterable)] * n\n" @@ -1995,7 +2003,139 @@ msgid "" " if first is not None:\n" " yield first()\n" " while True:\n" -" yield function()" +" yield function()\n" +"\n" +"# ==== Mathematical operations ====\n" +"\n" +"def multinomial(*counts):\n" +" \"Number of distinct arrangements of a multiset.\"\n" +" # Counter('abracadabra').values() → 5 2 2 1 1\n" +" # multinomial(5, 2, 2, 1, 1) → 83160\n" +" return prod(map(comb, accumulate(counts), counts))\n" +"\n" +"def powerset(iterable):\n" +" \"Subsequences of the iterable from shortest to longest.\"\n" +" # powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)\n" +" s = list(iterable)\n" +" return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))\n" +"\n" +"def sum_of_squares(iterable):\n" +" \"Add up the squares of the input values.\"\n" +" # sum_of_squares([10, 20, 30]) → 1400\n" +" return sumprod(*tee(iterable))\n" +"\n" +"# ==== Matrix operations ====\n" +"\n" +"def reshape(matrix, columns):\n" +" \"Reshape a 2-D matrix to have a given number of columns.\"\n" +" # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2) (3, 4, 5)\n" +" return batched(chain.from_iterable(matrix), columns, strict=True)\n" +"\n" +"def transpose(matrix):\n" +" \"Swap the rows and columns of a 2-D matrix.\"\n" +" # transpose([(1, 2, 3), (11, 22, 33)]) → (1, 11) (2, 22) (3, 33)\n" +" return zip(*matrix, strict=True)\n" +"\n" +"def matmul(m1, m2):\n" +" \"Multiply two matrices.\"\n" +" # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80) (41, 60)\n" +" n = len(m2[0])\n" +" return batched(starmap(sumprod, product(m1, transpose(m2))), n)\n" +"\n" +"# ==== Polynomial arithmetic ====\n" +"\n" +"def convolve(signal, kernel):\n" +" \"\"\"Discrete linear convolution of two iterables.\n" +" Equivalent to polynomial multiplication.\n" +"\n" +" Convolutions are mathematically commutative; however, the inputs are\n" +" evaluated differently. The signal is consumed lazily and can be\n" +" infinite. The kernel is fully consumed before the calculations begin.\n" +"\n" +" Article: https://betterexplained.com/articles/intuitive-convolution/\n" +" Video: https://www.youtube.com/watch?v=KuXjwB4LzSA\n" +" \"\"\"\n" +" # convolve([1, -1, -20], [1, -3]) → 1 -4 -17 60\n" +" # convolve(data, [0.25, 0.25, 0.25, 0.25]) → Moving average (blur)\n" +" # convolve(data, [1/2, 0, -1/2]) → 1st derivative estimate\n" +" # convolve(data, [1, -2, 1]) → 2nd derivative estimate\n" +" kernel = tuple(kernel)[::-1]\n" +" n = len(kernel)\n" +" padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))\n" +" windowed_signal = sliding_window(padded_signal, n)\n" +" return map(sumprod, repeat(kernel), windowed_signal)\n" +"\n" +"def polynomial_from_roots(roots):\n" +" \"\"\"Compute a polynomial's coefficients from its roots.\n" +"\n" +" (x - 5) (x + 4) (x - 3) expands to: x³ -4x² -17x + 60\n" +" \"\"\"\n" +" # polynomial_from_roots([5, -4, 3]) → [1, -4, -17, 60]\n" +" factors = zip(repeat(1), map(neg, roots))\n" +" return list(reduce(convolve, factors, [1]))\n" +"\n" +"def polynomial_eval(coefficients, x):\n" +" \"\"\"Evaluate a polynomial at a specific value.\n" +"\n" +" Computes with better numeric stability than Horner's method.\n" +" \"\"\"\n" +" # Evaluate x³ -4x² -17x + 60 at x = 5\n" +" # polynomial_eval([1, -4, -17, 60], x=5) → 0\n" +" n = len(coefficients)\n" +" if not n:\n" +" return type(x)(0)\n" +" powers = map(pow, repeat(x), reversed(range(n)))\n" +" return sumprod(coefficients, powers)\n" +"\n" +"def polynomial_derivative(coefficients):\n" +" \"\"\"Compute the first derivative of a polynomial.\n" +"\n" +" f(x) = x³ -4x² -17x + 60\n" +" f'(x) = 3x² -8x -17\n" +" \"\"\"\n" +" # polynomial_derivative([1, -4, -17, 60]) → [3, -8, -17]\n" +" n = len(coefficients)\n" +" powers = reversed(range(1, n))\n" +" return list(map(mul, coefficients, powers))\n" +"\n" +"# ==== Number theory ====\n" +"\n" +"def sieve(n):\n" +" \"Primes less than n.\"\n" +" # sieve(30) → 2 3 5 7 11 13 17 19 23 29\n" +" if n > 2:\n" +" yield 2\n" +" data = bytearray((0, 1)) * (n // 2)\n" +" for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1):\n" +" data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))\n" +" yield from iter_index(data, 1, start=3)\n" +"\n" +"def factor(n):\n" +" \"Prime factors of n.\"\n" +" # factor(99) → 3 3 11\n" +" # factor(1_000_000_000_000_007) → 47 59 360620266859\n" +" # factor(1_000_000_000_000_403) → 1000000000000403\n" +" for prime in sieve(isqrt(n) + 1):\n" +" while not n % prime:\n" +" yield prime\n" +" n //= prime\n" +" if n == 1:\n" +" return\n" +" if n > 1:\n" +" yield n\n" +"\n" +"def is_prime(n):\n" +" \"Return True if n is prime.\"\n" +" # is_prime(1_000_000_000_000_403) → True\n" +" return n > 1 and next(factor(n)) == n\n" +"\n" +"def totient(n):\n" +" \"Count of natural numbers up to n that are coprime to n.\"\n" +" # https://mathworld.wolfram.com/TotientFunction.html\n" +" # totient(12) → 4 because len([1, 5, 7, 11]) == 4\n" +" for prime in set(factor(n)):\n" +" n -= n // prime\n" +" return n" msgstr "" "from collections import Counter, deque\n" "from contextlib import suppress\n" @@ -2174,255 +2314,257 @@ msgstr "" " while True:\n" " yield function()" -#: ../../library/itertools.rst:1018 -msgid "The following recipes have a more mathematical flavor:" -msgstr "以下的應用技巧具有更多的數學風格:" - -#: ../../library/itertools.rst:1020 -msgid "" -"def multinomial(*counts):\n" -" \"Number of distinct arrangements of a multiset.\"\n" -" # Counter('abracadabra').values() → 5 2 2 1 1\n" -" # multinomial(5, 2, 2, 1, 1) → 83160\n" -" return prod(map(comb, accumulate(counts), counts))\n" -"\n" -"def powerset(iterable):\n" -" \"Subsequences of the iterable from shortest to longest.\"\n" -" # powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)\n" -" s = list(iterable)\n" -" return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))\n" -"\n" -"def sum_of_squares(iterable):\n" -" \"Add up the squares of the input values.\"\n" -" # sum_of_squares([10, 20, 30]) → 1400\n" -" return sumprod(*tee(iterable))\n" -"\n" -"def reshape(matrix, columns):\n" -" \"Reshape a 2-D matrix to have a given number of columns.\"\n" -" # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2), (3, 4, 5)\n" -" return batched(chain.from_iterable(matrix), columns, strict=True)\n" -"\n" -"def transpose(matrix):\n" -" \"Swap the rows and columns of a 2-D matrix.\"\n" -" # transpose([(1, 2, 3), (11, 22, 33)]) → (1, 11) (2, 22) (3, 33)\n" -" return zip(*matrix, strict=True)\n" -"\n" -"def matmul(m1, m2):\n" -" \"Multiply two matrices.\"\n" -" # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80), (41, 60)\n" -" n = len(m2[0])\n" -" return batched(starmap(sumprod, product(m1, transpose(m2))), n)\n" -"\n" -"def convolve(signal, kernel):\n" -" \"\"\"Discrete linear convolution of two iterables.\n" -" Equivalent to polynomial multiplication.\n" -"\n" -" Convolutions are mathematically commutative; however, the inputs are\n" -" evaluated differently. The signal is consumed lazily and can be\n" -" infinite. The kernel is fully consumed before the calculations begin.\n" -"\n" -" Article: https://betterexplained.com/articles/intuitive-convolution/\n" -" Video: https://www.youtube.com/watch?v=KuXjwB4LzSA\n" -" \"\"\"\n" -" # convolve([1, -1, -20], [1, -3]) → 1 -4 -17 60\n" -" # convolve(data, [0.25, 0.25, 0.25, 0.25]) → Moving average (blur)\n" -" # convolve(data, [1/2, 0, -1/2]) → 1st derivative estimate\n" -" # convolve(data, [1, -2, 1]) → 2nd derivative estimate\n" -" kernel = tuple(kernel)[::-1]\n" -" n = len(kernel)\n" -" padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))\n" -" windowed_signal = sliding_window(padded_signal, n)\n" -" return map(sumprod, repeat(kernel), windowed_signal)\n" -"\n" -"def polynomial_from_roots(roots):\n" -" \"\"\"Compute a polynomial's coefficients from its roots.\n" -"\n" -" (x - 5) (x + 4) (x - 3) expands to: x³ -4x² -17x + 60\n" -" \"\"\"\n" -" # polynomial_from_roots([5, -4, 3]) → [1, -4, -17, 60]\n" -" factors = zip(repeat(1), map(neg, roots))\n" -" return list(reduce(convolve, factors, [1]))\n" -"\n" -"def polynomial_eval(coefficients, x):\n" -" \"\"\"Evaluate a polynomial at a specific value.\n" -"\n" -" Computes with better numeric stability than Horner's method.\n" -" \"\"\"\n" -" # Evaluate x³ -4x² -17x + 60 at x = 5\n" -" # polynomial_eval([1, -4, -17, 60], x=5) → 0\n" -" n = len(coefficients)\n" -" if not n:\n" -" return type(x)(0)\n" -" powers = map(pow, repeat(x), reversed(range(n)))\n" -" return sumprod(coefficients, powers)\n" -"\n" -"def polynomial_derivative(coefficients):\n" -" \"\"\"Compute the first derivative of a polynomial.\n" -"\n" -" f(x) = x³ -4x² -17x + 60\n" -" f'(x) = 3x² -8x -17\n" -" \"\"\"\n" -" # polynomial_derivative([1, -4, -17, 60]) → [3, -8, -17]\n" -" n = len(coefficients)\n" -" powers = reversed(range(1, n))\n" -" return list(map(mul, coefficients, powers))\n" -"\n" -"def sieve(n):\n" -" \"Primes less than n.\"\n" -" # sieve(30) → 2 3 5 7 11 13 17 19 23 29\n" -" if n > 2:\n" -" yield 2\n" -" data = bytearray((0, 1)) * (n // 2)\n" -" for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1):\n" -" data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))\n" -" yield from iter_index(data, 1, start=3)\n" -"\n" -"def factor(n):\n" -" \"Prime factors of n.\"\n" -" # factor(99) → 3 3 11\n" -" # factor(1_000_000_000_000_007) → 47 59 360620266859\n" -" # factor(1_000_000_000_000_403) → 1000000000000403\n" -" for prime in sieve(isqrt(n) + 1):\n" -" while not n % prime:\n" -" yield prime\n" -" n //= prime\n" -" if n == 1:\n" -" return\n" -" if n > 1:\n" -" yield n\n" -"\n" -"def is_prime(n):\n" -" \"Return True if n is prime.\"\n" -" # is_prime(1_000_000_000_000_403) → True\n" -" return n > 1 and next(factor(n)) == n\n" -"\n" -"def totient(n):\n" -" \"Count of natural numbers up to n that are coprime to n.\"\n" -" # https://mathworld.wolfram.com/TotientFunction.html\n" -" # totient(12) → 4 because len([1, 5, 7, 11]) == 4\n" -" for prime in set(factor(n)):\n" -" n -= n // prime\n" -" return n" -msgstr "" -"def multinomial(*counts):\n" -" \"多重集合的不同排列數。\"\n" -" # Counter('abracadabra').values() → 5 2 2 1 1\n" -" # multinomial(5, 2, 2, 1, 1) → 83160\n" -" return prod(map(comb, accumulate(counts), counts))\n" -"\n" -"def powerset(iterable):\n" -" \"來自可疊代物件的子序列,從最短到最長。\"\n" -" # powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)\n" -" s = list(iterable)\n" -" return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))\n" -"\n" -"def sum_of_squares(iterable):\n" -" \"將輸入值的平方加總。\"\n" -" # sum_of_squares([10, 20, 30]) → 1400\n" -" return sumprod(*tee(iterable))\n" -"\n" -"def reshape(matrix, columns):\n" -" \"將 2 維矩陣重新塑形為指定的行數。\"\n" -" # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2), (3, 4, 5)\n" -" return batched(chain.from_iterable(matrix), columns, strict=True)\n" -"\n" -"def transpose(matrix):\n" -" \"交換 2 維矩陣的列和行。\"\n" -" # transpose([(1, 2, 3), (11, 22, 33)]) → (1, 11) (2, 22) (3, 33)\n" -" return zip(*matrix, strict=True)\n" -"\n" -"def matmul(m1, m2):\n" -" \"矩陣相乘。\"\n" -" # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80), (41, 60)\n" -" n = len(m2[0])\n" -" return batched(starmap(sumprod, product(m1, transpose(m2))), n)\n" -"\n" -"def convolve(signal, kernel):\n" -" \"\"\"兩個可疊代物件的離散線性捲積。\n" -" 等同於多項式相乘。\n" -"\n" -" 在數學上捲積是可交換的;但輸入的處理方式不同。\n" -" 訊號以惰性方式被讀取,且可以是無限;核心會在計算開始前被全部讀取。\n" -"\n" -" 文章:https://betterexplained.com/articles/intuitive-convolution/\n" -" 影片:https://www.youtube.com/watch?v=KuXjwB4LzSA\n" -" \"\"\"\n" -" # convolve([1, -1, -20], [1, -3]) → 1 -4 -17 60\n" -" # convolve(data, [0.25, 0.25, 0.25, 0.25]) → 移動平均(模糊)\n" -" # convolve(data, [1/2, 0, -1/2]) → 一階導數估計\n" -" # convolve(data, [1, -2, 1]) → 二階導數估計\n" -" kernel = tuple(kernel)[::-1]\n" -" n = len(kernel)\n" -" padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))\n" -" windowed_signal = sliding_window(padded_signal, n)\n" -" return map(sumprod, repeat(kernel), windowed_signal)\n" -"\n" -"def polynomial_from_roots(roots):\n" -" \"\"\"由多項式的根計算其係數。\n" -"\n" -" (x - 5) (x + 4) (x - 3) 展開為: x³ -4x² -17x + 60\n" -" \"\"\"\n" -" # polynomial_from_roots([5, -4, 3]) → [1, -4, -17, 60]\n" -" factors = zip(repeat(1), map(neg, roots))\n" -" return list(reduce(convolve, factors, [1]))\n" -"\n" -"def polynomial_eval(coefficients, x):\n" -" \"\"\"在指定值計算多項式的值。\n" -"\n" -" 此方法在數值穩定性上比 Horner 方法更好。\n" -" \"\"\"\n" -" # 計算 x³ -4x² -17x + 60 在 x = 5 時的值\n" -" # polynomial_eval([1, -4, -17, 60], x=5) → 0\n" -" n = len(coefficients)\n" -" if not n:\n" -" return type(x)(0)\n" -" powers = map(pow, repeat(x), reversed(range(n)))\n" -" return sumprod(coefficients, powers)\n" -"\n" -"def polynomial_derivative(coefficients):\n" -" \"\"\"計算多項式的一階導數。\n" -"\n" -" f(x) = x³ -4x² -17x + 60\n" -" f'(x) = 3x² -8x -17\n" -" \"\"\"\n" -" # polynomial_derivative([1, -4, -17, 60]) → [3, -8, -17]\n" -" n = len(coefficients)\n" -" powers = reversed(range(1, n))\n" -" return list(map(mul, coefficients, powers))\n" -"\n" -"def sieve(n):\n" -" \"小於 n 的質數。\"\n" -" # sieve(30) → 2 3 5 7 11 13 17 19 23 29\n" -" if n > 2:\n" -" yield 2\n" -" data = bytearray((0, 1)) * (n // 2)\n" -" for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1):\n" -" data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))\n" -" yield from iter_index(data, 1, start=3)\n" -"\n" -"def factor(n):\n" -" \"n 的質因數。\"\n" -" # factor(99) → 3 3 11\n" -" # factor(1_000_000_000_000_007) → 47 59 360620266859\n" -" # factor(1_000_000_000_000_403) → 1000000000000403\n" -" for prime in sieve(isqrt(n) + 1):\n" -" while not n % prime:\n" -" yield prime\n" -" n //= prime\n" -" if n == 1:\n" -" return\n" -" if n > 1:\n" -" yield n\n" -"\n" -"def is_prime(n):\n" -" \"回傳 True,若 n 為質數。\"\n" -" # is_prime(1_000_000_000_000_403) → True\n" -" return n > 1 and next(factor(n)) == n\n" -"\n" -"def totient(n):\n" -" \"計算不大於 n 且與 n 互質的自然數個數。\"\n" -" # https://mathworld.wolfram.com/TotientFunction.html\n" -" # totient(12) → 4 因爲 len([1, 5, 7, 11]) == 4\n" -" for prime in set(factor(n)):\n" -" n -= n // prime\n" -" return n" +#~ msgid "The following recipes have a more mathematical flavor:" +#~ msgstr "以下的應用技巧具有更多的數學風格:" + +#~ msgid "" +#~ "def multinomial(*counts):\n" +#~ " \"Number of distinct arrangements of a multiset.\"\n" +#~ " # Counter('abracadabra').values() → 5 2 2 1 1\n" +#~ " # multinomial(5, 2, 2, 1, 1) → 83160\n" +#~ " return prod(map(comb, accumulate(counts), counts))\n" +#~ "\n" +#~ "def powerset(iterable):\n" +#~ " \"Subsequences of the iterable from shortest to longest.\"\n" +#~ " # powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)\n" +#~ " s = list(iterable)\n" +#~ " return chain.from_iterable(combinations(s, r) for r in " +#~ "range(len(s)+1))\n" +#~ "\n" +#~ "def sum_of_squares(iterable):\n" +#~ " \"Add up the squares of the input values.\"\n" +#~ " # sum_of_squares([10, 20, 30]) → 1400\n" +#~ " return sumprod(*tee(iterable))\n" +#~ "\n" +#~ "def reshape(matrix, columns):\n" +#~ " \"Reshape a 2-D matrix to have a given number of columns.\"\n" +#~ " # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2), (3, 4, 5)\n" +#~ " return batched(chain.from_iterable(matrix), columns, strict=True)\n" +#~ "\n" +#~ "def transpose(matrix):\n" +#~ " \"Swap the rows and columns of a 2-D matrix.\"\n" +#~ " # transpose([(1, 2, 3), (11, 22, 33)]) → (1, 11) (2, 22) (3, 33)\n" +#~ " return zip(*matrix, strict=True)\n" +#~ "\n" +#~ "def matmul(m1, m2):\n" +#~ " \"Multiply two matrices.\"\n" +#~ " # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80), (41, 60)\n" +#~ " n = len(m2[0])\n" +#~ " return batched(starmap(sumprod, product(m1, transpose(m2))), n)\n" +#~ "\n" +#~ "def convolve(signal, kernel):\n" +#~ " \"\"\"Discrete linear convolution of two iterables.\n" +#~ " Equivalent to polynomial multiplication.\n" +#~ "\n" +#~ " Convolutions are mathematically commutative; however, the inputs are\n" +#~ " evaluated differently. The signal is consumed lazily and can be\n" +#~ " infinite. The kernel is fully consumed before the calculations " +#~ "begin.\n" +#~ "\n" +#~ " Article: https://betterexplained.com/articles/intuitive-" +#~ "convolution/\n" +#~ " Video: https://www.youtube.com/watch?v=KuXjwB4LzSA\n" +#~ " \"\"\"\n" +#~ " # convolve([1, -1, -20], [1, -3]) → 1 -4 -17 60\n" +#~ " # convolve(data, [0.25, 0.25, 0.25, 0.25]) → Moving average (blur)\n" +#~ " # convolve(data, [1/2, 0, -1/2]) → 1st derivative estimate\n" +#~ " # convolve(data, [1, -2, 1]) → 2nd derivative estimate\n" +#~ " kernel = tuple(kernel)[::-1]\n" +#~ " n = len(kernel)\n" +#~ " padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))\n" +#~ " windowed_signal = sliding_window(padded_signal, n)\n" +#~ " return map(sumprod, repeat(kernel), windowed_signal)\n" +#~ "\n" +#~ "def polynomial_from_roots(roots):\n" +#~ " \"\"\"Compute a polynomial's coefficients from its roots.\n" +#~ "\n" +#~ " (x - 5) (x + 4) (x - 3) expands to: x³ -4x² -17x + 60\n" +#~ " \"\"\"\n" +#~ " # polynomial_from_roots([5, -4, 3]) → [1, -4, -17, 60]\n" +#~ " factors = zip(repeat(1), map(neg, roots))\n" +#~ " return list(reduce(convolve, factors, [1]))\n" +#~ "\n" +#~ "def polynomial_eval(coefficients, x):\n" +#~ " \"\"\"Evaluate a polynomial at a specific value.\n" +#~ "\n" +#~ " Computes with better numeric stability than Horner's method.\n" +#~ " \"\"\"\n" +#~ " # Evaluate x³ -4x² -17x + 60 at x = 5\n" +#~ " # polynomial_eval([1, -4, -17, 60], x=5) → 0\n" +#~ " n = len(coefficients)\n" +#~ " if not n:\n" +#~ " return type(x)(0)\n" +#~ " powers = map(pow, repeat(x), reversed(range(n)))\n" +#~ " return sumprod(coefficients, powers)\n" +#~ "\n" +#~ "def polynomial_derivative(coefficients):\n" +#~ " \"\"\"Compute the first derivative of a polynomial.\n" +#~ "\n" +#~ " f(x) = x³ -4x² -17x + 60\n" +#~ " f'(x) = 3x² -8x -17\n" +#~ " \"\"\"\n" +#~ " # polynomial_derivative([1, -4, -17, 60]) → [3, -8, -17]\n" +#~ " n = len(coefficients)\n" +#~ " powers = reversed(range(1, n))\n" +#~ " return list(map(mul, coefficients, powers))\n" +#~ "\n" +#~ "def sieve(n):\n" +#~ " \"Primes less than n.\"\n" +#~ " # sieve(30) → 2 3 5 7 11 13 17 19 23 29\n" +#~ " if n > 2:\n" +#~ " yield 2\n" +#~ " data = bytearray((0, 1)) * (n // 2)\n" +#~ " for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1):\n" +#~ " data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))\n" +#~ " yield from iter_index(data, 1, start=3)\n" +#~ "\n" +#~ "def factor(n):\n" +#~ " \"Prime factors of n.\"\n" +#~ " # factor(99) → 3 3 11\n" +#~ " # factor(1_000_000_000_000_007) → 47 59 360620266859\n" +#~ " # factor(1_000_000_000_000_403) → 1000000000000403\n" +#~ " for prime in sieve(isqrt(n) + 1):\n" +#~ " while not n % prime:\n" +#~ " yield prime\n" +#~ " n //= prime\n" +#~ " if n == 1:\n" +#~ " return\n" +#~ " if n > 1:\n" +#~ " yield n\n" +#~ "\n" +#~ "def is_prime(n):\n" +#~ " \"Return True if n is prime.\"\n" +#~ " # is_prime(1_000_000_000_000_403) → True\n" +#~ " return n > 1 and next(factor(n)) == n\n" +#~ "\n" +#~ "def totient(n):\n" +#~ " \"Count of natural numbers up to n that are coprime to n.\"\n" +#~ " # https://mathworld.wolfram.com/TotientFunction.html\n" +#~ " # totient(12) → 4 because len([1, 5, 7, 11]) == 4\n" +#~ " for prime in set(factor(n)):\n" +#~ " n -= n // prime\n" +#~ " return n" +#~ msgstr "" +#~ "def multinomial(*counts):\n" +#~ " \"多重集合的不同排列數。\"\n" +#~ " # Counter('abracadabra').values() → 5 2 2 1 1\n" +#~ " # multinomial(5, 2, 2, 1, 1) → 83160\n" +#~ " return prod(map(comb, accumulate(counts), counts))\n" +#~ "\n" +#~ "def powerset(iterable):\n" +#~ " \"來自可疊代物件的子序列,從最短到最長。\"\n" +#~ " # powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)\n" +#~ " s = list(iterable)\n" +#~ " return chain.from_iterable(combinations(s, r) for r in " +#~ "range(len(s)+1))\n" +#~ "\n" +#~ "def sum_of_squares(iterable):\n" +#~ " \"將輸入值的平方加總。\"\n" +#~ " # sum_of_squares([10, 20, 30]) → 1400\n" +#~ " return sumprod(*tee(iterable))\n" +#~ "\n" +#~ "def reshape(matrix, columns):\n" +#~ " \"將 2 維矩陣重新塑形為指定的行數。\"\n" +#~ " # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2), (3, 4, 5)\n" +#~ " return batched(chain.from_iterable(matrix), columns, strict=True)\n" +#~ "\n" +#~ "def transpose(matrix):\n" +#~ " \"交換 2 維矩陣的列和行。\"\n" +#~ " # transpose([(1, 2, 3), (11, 22, 33)]) → (1, 11) (2, 22) (3, 33)\n" +#~ " return zip(*matrix, strict=True)\n" +#~ "\n" +#~ "def matmul(m1, m2):\n" +#~ " \"矩陣相乘。\"\n" +#~ " # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80), (41, 60)\n" +#~ " n = len(m2[0])\n" +#~ " return batched(starmap(sumprod, product(m1, transpose(m2))), n)\n" +#~ "\n" +#~ "def convolve(signal, kernel):\n" +#~ " \"\"\"兩個可疊代物件的離散線性捲積。\n" +#~ " 等同於多項式相乘。\n" +#~ "\n" +#~ " 在數學上捲積是可交換的;但輸入的處理方式不同。\n" +#~ " 訊號以惰性方式被讀取,且可以是無限;核心會在計算開始前被全部讀取。\n" +#~ "\n" +#~ " 文章:https://betterexplained.com/articles/intuitive-convolution/\n" +#~ " 影片:https://www.youtube.com/watch?v=KuXjwB4LzSA\n" +#~ " \"\"\"\n" +#~ " # convolve([1, -1, -20], [1, -3]) → 1 -4 -17 60\n" +#~ " # convolve(data, [0.25, 0.25, 0.25, 0.25]) → 移動平均(模糊)\n" +#~ " # convolve(data, [1/2, 0, -1/2]) → 一階導數估計\n" +#~ " # convolve(data, [1, -2, 1]) → 二階導數估計\n" +#~ " kernel = tuple(kernel)[::-1]\n" +#~ " n = len(kernel)\n" +#~ " padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))\n" +#~ " windowed_signal = sliding_window(padded_signal, n)\n" +#~ " return map(sumprod, repeat(kernel), windowed_signal)\n" +#~ "\n" +#~ "def polynomial_from_roots(roots):\n" +#~ " \"\"\"由多項式的根計算其係數。\n" +#~ "\n" +#~ " (x - 5) (x + 4) (x - 3) 展開為: x³ -4x² -17x + 60\n" +#~ " \"\"\"\n" +#~ " # polynomial_from_roots([5, -4, 3]) → [1, -4, -17, 60]\n" +#~ " factors = zip(repeat(1), map(neg, roots))\n" +#~ " return list(reduce(convolve, factors, [1]))\n" +#~ "\n" +#~ "def polynomial_eval(coefficients, x):\n" +#~ " \"\"\"在指定值計算多項式的值。\n" +#~ "\n" +#~ " 此方法在數值穩定性上比 Horner 方法更好。\n" +#~ " \"\"\"\n" +#~ " # 計算 x³ -4x² -17x + 60 在 x = 5 時的值\n" +#~ " # polynomial_eval([1, -4, -17, 60], x=5) → 0\n" +#~ " n = len(coefficients)\n" +#~ " if not n:\n" +#~ " return type(x)(0)\n" +#~ " powers = map(pow, repeat(x), reversed(range(n)))\n" +#~ " return sumprod(coefficients, powers)\n" +#~ "\n" +#~ "def polynomial_derivative(coefficients):\n" +#~ " \"\"\"計算多項式的一階導數。\n" +#~ "\n" +#~ " f(x) = x³ -4x² -17x + 60\n" +#~ " f'(x) = 3x² -8x -17\n" +#~ " \"\"\"\n" +#~ " # polynomial_derivative([1, -4, -17, 60]) → [3, -8, -17]\n" +#~ " n = len(coefficients)\n" +#~ " powers = reversed(range(1, n))\n" +#~ " return list(map(mul, coefficients, powers))\n" +#~ "\n" +#~ "def sieve(n):\n" +#~ " \"小於 n 的質數。\"\n" +#~ " # sieve(30) → 2 3 5 7 11 13 17 19 23 29\n" +#~ " if n > 2:\n" +#~ " yield 2\n" +#~ " data = bytearray((0, 1)) * (n // 2)\n" +#~ " for p in iter_index(data, 1, start=3, stop=isqrt(n) + 1):\n" +#~ " data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))\n" +#~ " yield from iter_index(data, 1, start=3)\n" +#~ "\n" +#~ "def factor(n):\n" +#~ " \"n 的質因數。\"\n" +#~ " # factor(99) → 3 3 11\n" +#~ " # factor(1_000_000_000_000_007) → 47 59 360620266859\n" +#~ " # factor(1_000_000_000_000_403) → 1000000000000403\n" +#~ " for prime in sieve(isqrt(n) + 1):\n" +#~ " while not n % prime:\n" +#~ " yield prime\n" +#~ " n //= prime\n" +#~ " if n == 1:\n" +#~ " return\n" +#~ " if n > 1:\n" +#~ " yield n\n" +#~ "\n" +#~ "def is_prime(n):\n" +#~ " \"回傳 True,若 n 為質數。\"\n" +#~ " # is_prime(1_000_000_000_000_403) → True\n" +#~ " return n > 1 and next(factor(n)) == n\n" +#~ "\n" +#~ "def totient(n):\n" +#~ " \"計算不大於 n 且與 n 互質的自然數個數。\"\n" +#~ " # https://mathworld.wolfram.com/TotientFunction.html\n" +#~ " # totient(12) → 4 因爲 len([1, 5, 7, 11]) == 4\n" +#~ " for prime in set(factor(n)):\n" +#~ " n -= n // prime\n" +#~ " return n" diff --git a/library/stdtypes.po b/library/stdtypes.po index bd19a266d3c..dd4f406934e 100644 --- a/library/stdtypes.po +++ b/library/stdtypes.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-01-12 00:16+0000\n" +"POT-Creation-Date: 2026-01-13 00:13+0000\n" "PO-Revision-Date: 2022-06-12 15:22+0800\n" "Last-Translator: Matt Wang \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -139,8 +139,8 @@ msgstr "結果" #: ../../library/stdtypes.rst:88 ../../library/stdtypes.rst:284 #: ../../library/stdtypes.rst:424 ../../library/stdtypes.rst:1007 -#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:3011 -#: ../../library/stdtypes.rst:4271 +#: ../../library/stdtypes.rst:1229 ../../library/stdtypes.rst:3114 +#: ../../library/stdtypes.rst:4374 msgid "Notes" msgstr "註解" @@ -154,7 +154,7 @@ msgstr "假如 *x* 為真,則 *x*,否則 *y*" #: ../../library/stdtypes.rst:90 ../../library/stdtypes.rst:1009 #: ../../library/stdtypes.rst:1012 ../../library/stdtypes.rst:1244 -#: ../../library/stdtypes.rst:3017 ../../library/stdtypes.rst:4277 +#: ../../library/stdtypes.rst:3120 ../../library/stdtypes.rst:4380 msgid "\\(1)" msgstr "\\(1)" @@ -168,8 +168,8 @@ msgstr "假如 *x* 為假,則 *x*,否則 *y*" #: ../../library/stdtypes.rst:93 ../../library/stdtypes.rst:297 #: ../../library/stdtypes.rst:317 ../../library/stdtypes.rst:1255 -#: ../../library/stdtypes.rst:3021 ../../library/stdtypes.rst:3023 -#: ../../library/stdtypes.rst:4281 ../../library/stdtypes.rst:4283 +#: ../../library/stdtypes.rst:3124 ../../library/stdtypes.rst:3126 +#: ../../library/stdtypes.rst:4384 ../../library/stdtypes.rst:4386 msgid "\\(2)" msgstr "\\(2)" @@ -181,18 +181,18 @@ msgstr "``not x``" msgid "if *x* is false, then ``True``, else ``False``" msgstr "假如 *x* 為假,則 ``True``,否則 ``False``" -#: ../../library/stdtypes.rst:96 ../../library/stdtypes.rst:3025 -#: ../../library/stdtypes.rst:3027 ../../library/stdtypes.rst:3029 -#: ../../library/stdtypes.rst:3031 ../../library/stdtypes.rst:4285 -#: ../../library/stdtypes.rst:4287 ../../library/stdtypes.rst:4289 -#: ../../library/stdtypes.rst:4291 +#: ../../library/stdtypes.rst:96 ../../library/stdtypes.rst:3128 +#: ../../library/stdtypes.rst:3130 ../../library/stdtypes.rst:3132 +#: ../../library/stdtypes.rst:3134 ../../library/stdtypes.rst:4388 +#: ../../library/stdtypes.rst:4390 ../../library/stdtypes.rst:4392 +#: ../../library/stdtypes.rst:4394 msgid "\\(3)" msgstr "\\(3)" #: ../../library/stdtypes.rst:105 ../../library/stdtypes.rst:328 #: ../../library/stdtypes.rst:442 ../../library/stdtypes.rst:1051 -#: ../../library/stdtypes.rst:1259 ../../library/stdtypes.rst:3057 -#: ../../library/stdtypes.rst:4321 +#: ../../library/stdtypes.rst:1259 ../../library/stdtypes.rst:3160 +#: ../../library/stdtypes.rst:4424 msgid "Notes:" msgstr "註解:" @@ -239,9 +239,9 @@ msgstr "" msgid "This table summarizes the comparison operations:" msgstr "這個表格統整所有比較運算:" -#: ../../library/stdtypes.rst:146 ../../library/stdtypes.rst:2988 -#: ../../library/stdtypes.rst:3011 ../../library/stdtypes.rst:4248 -#: ../../library/stdtypes.rst:4271 +#: ../../library/stdtypes.rst:146 ../../library/stdtypes.rst:3091 +#: ../../library/stdtypes.rst:3114 ../../library/stdtypes.rst:4351 +#: ../../library/stdtypes.rst:4374 msgid "Meaning" msgstr "含義" @@ -352,8 +352,8 @@ msgid "" "customized; also they can be applied to any two objects and never raise an " "exception." msgstr "" -"無法自訂 :keyword:`is` 與 :keyword:`is not` 運算子的行為;這兩個運算子也可" -"以運用在任意兩個物件且不會引發例外。" +"無法自訂 :keyword:`is` 與 :keyword:`is not` 運算子的行為;這兩個運算子也可以" +"運用在任意兩個物件且不會引發例外。" #: ../../library/stdtypes.rst:201 msgid "" @@ -574,8 +574,8 @@ msgid "" "zero." msgstr "一個複數,其實部為 *re*,虛部為 *im*。*im* 預設為零。" -#: ../../library/stdtypes.rst:310 ../../library/stdtypes.rst:3019 -#: ../../library/stdtypes.rst:4308 +#: ../../library/stdtypes.rst:310 ../../library/stdtypes.rst:3122 +#: ../../library/stdtypes.rst:4411 msgid "\\(6)" msgstr "\\(6)" @@ -612,9 +612,9 @@ msgid "*x* to the power *y*" msgstr "*x* 的 *y* 次方" #: ../../library/stdtypes.rst:319 ../../library/stdtypes.rst:321 -#: ../../library/stdtypes.rst:3044 ../../library/stdtypes.rst:3047 -#: ../../library/stdtypes.rst:3050 ../../library/stdtypes.rst:4304 -#: ../../library/stdtypes.rst:4311 +#: ../../library/stdtypes.rst:3147 ../../library/stdtypes.rst:3150 +#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4407 +#: ../../library/stdtypes.rst:4414 msgid "\\(5)" msgstr "\\(5)" @@ -772,9 +772,9 @@ msgid "bitwise :dfn:`or` of *x* and *y*" msgstr "*x* 及 *y* 的位元 :dfn:`或`" #: ../../library/stdtypes.rst:426 ../../library/stdtypes.rst:429 -#: ../../library/stdtypes.rst:432 ../../library/stdtypes.rst:3033 -#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:4293 -#: ../../library/stdtypes.rst:4297 +#: ../../library/stdtypes.rst:432 ../../library/stdtypes.rst:3136 +#: ../../library/stdtypes.rst:3140 ../../library/stdtypes.rst:4396 +#: ../../library/stdtypes.rst:4400 msgid "\\(4)" msgstr "\\(4)" @@ -1508,8 +1508,8 @@ msgid "" "support the iteration methods." msgstr "" "Python 支援對容器的疊代概念。這是實作兩種不同的 methods;這些方法被用於允許使" -"用者定義的 classes 以支援疊代。序列則總是支援這些疊代 methods,在下方有更詳" -"細的描述。" +"用者定義的 classes 以支援疊代。序列則總是支援這些疊代 methods,在下方有更詳細" +"的描述。" #: ../../library/stdtypes.rst:902 msgid "" @@ -2254,11 +2254,159 @@ msgid "" "detect that the list has been mutated during a sort." msgstr "" -#: ../../library/stdtypes.rst:1448 +#: ../../library/stdtypes.rst:1444 +msgid "Thread safety" +msgstr "" + +#: ../../library/stdtypes.rst:1446 +msgid "" +"Reading a single element from a :class:`list` is :term:`atomic `:" +msgstr "" + +#: ../../library/stdtypes.rst:1449 +msgid "lst[i] # list.__getitem__" +msgstr "" + +#: ../../library/stdtypes.rst:1454 +msgid "" +"The following methods traverse the list and use :term:`atomic ` reads of each item to perform their function. That means that " +"they may return results affected by concurrent modifications:" +msgstr "" + +#: ../../library/stdtypes.rst:1458 +msgid "" +"item in lst\n" +"lst.index(item)\n" +"lst.count(item)" +msgstr "" + +#: ../../library/stdtypes.rst:1465 +msgid "" +"All of the above methods/operations are also lock-free. They do not block " +"concurrent modifications. Other operations that hold a lock will not block " +"these from observing intermediate states." +msgstr "" + +#: ../../library/stdtypes.rst:1469 +msgid "All other operations from here on block using the per-object lock." +msgstr "" + +#: ../../library/stdtypes.rst:1471 +msgid "" +"Writing a single item via ``lst[i] = x`` is safe to call from multiple " +"threads and will not corrupt the list." +msgstr "" + +#: ../../library/stdtypes.rst:1474 +msgid "" +"The following operations return new objects and appear :term:`atomic ` to other threads:" +msgstr "" + +#: ../../library/stdtypes.rst:1477 +msgid "" +"lst1 + lst2 # concatenates two lists into a new list\n" +"x * lst # repeats lst x times into a new list\n" +"lst.copy() # returns a shallow copy of the list" +msgstr "" + +#: ../../library/stdtypes.rst:1484 +msgid "" +"Methods that only operate on a single elements with no shifting required " +"are :term:`atomic `:" +msgstr "" + +#: ../../library/stdtypes.rst:1487 +msgid "" +"lst.append(x) # append to the end of the list, no shifting required\n" +"lst.pop() # pop element from the end of the list, no shifting required" +msgstr "" + +#: ../../library/stdtypes.rst:1493 +msgid "" +"The :meth:`~list.clear` method is also :term:`atomic `. " +"Other threads cannot observe elements being removed." +msgstr "" + +#: ../../library/stdtypes.rst:1496 +msgid "" +"The :meth:`~list.sort` method is not :term:`atomic `. " +"Other threads cannot observe intermediate states during sorting, but the " +"list appears empty for the duration of the sort." +msgstr "" + +#: ../../library/stdtypes.rst:1500 +msgid "" +"The following operations may allow lock-free operations to observe " +"intermediate states since they modify multiple elements in place:" +msgstr "" + +#: ../../library/stdtypes.rst:1503 +msgid "" +"lst.insert(idx, item) # shifts elements\n" +"lst.pop(idx) # idx not at the end of the list, shifts elements\n" +"lst *= x # copies elements in place" +msgstr "" + +#: ../../library/stdtypes.rst:1510 +msgid "" +"The :meth:`~list.remove` method may allow concurrent modifications since " +"element comparison may execute arbitrary Python code (via :meth:`~object." +"__eq__`)." +msgstr "" + +#: ../../library/stdtypes.rst:1514 +msgid "" +":meth:`~list.extend` is safe to call from multiple threads. However, its " +"guarantees depend on the iterable passed to it. If it is a :class:`list`, a :" +"class:`tuple`, a :class:`set`, a :class:`frozenset`, a :class:`dict` or a :" +"ref:`dictionary view object ` (but not their subclasses), the " +"``extend`` operation is safe from concurrent modifications to the iterable. " +"Otherwise, an iterator is created which can be concurrently modified by " +"another thread. The same applies to inplace concatenation of a list with " +"other iterables when using ``lst += iterable``." +msgstr "" + +#: ../../library/stdtypes.rst:1523 +msgid "" +"Similarly, assigning to a list slice with ``lst[i:j] = iterable`` is safe to " +"call from multiple threads, but ``iterable`` is only locked when it is also " +"a :class:`list` (but not its subclasses)." +msgstr "" + +#: ../../library/stdtypes.rst:1527 +msgid "" +"Operations that involve multiple accesses, as well as iteration, are never " +"atomic. For example:" +msgstr "" + +#: ../../library/stdtypes.rst:1530 +msgid "" +"# NOT atomic: read-modify-write\n" +"lst[i] = lst[i] + 1\n" +"\n" +"# NOT atomic: check-then-act\n" +"if lst:\n" +" item = lst.pop()\n" +"\n" +"# NOT thread-safe: iteration while modifying\n" +"for item in lst:\n" +" process(item) # another thread may modify lst" +msgstr "" + +#: ../../library/stdtypes.rst:1544 +msgid "" +"Consider external synchronization when sharing :class:`list` instances " +"across threads. See :ref:`freethreading-python-howto` for more information." +msgstr "" + +#: ../../library/stdtypes.rst:1551 msgid "Tuples" msgstr "Tuple(元組)" -#: ../../library/stdtypes.rst:1452 +#: ../../library/stdtypes.rst:1555 msgid "" "Tuples are immutable sequences, typically used to store collections of " "heterogeneous data (such as the 2-tuples produced by the :func:`enumerate` " @@ -2267,27 +2415,27 @@ msgid "" "class:`dict` instance)." msgstr "" -#: ../../library/stdtypes.rst:1460 +#: ../../library/stdtypes.rst:1563 msgid "Tuples may be constructed in a number of ways:" msgstr "元組可以以多種方式建構:" -#: ../../library/stdtypes.rst:1462 +#: ../../library/stdtypes.rst:1565 msgid "Using a pair of parentheses to denote the empty tuple: ``()``" msgstr "使用一對圓括號表示空元組:``()``" -#: ../../library/stdtypes.rst:1463 +#: ../../library/stdtypes.rst:1566 msgid "Using a trailing comma for a singleton tuple: ``a,`` or ``(a,)``" msgstr "使用末尾的逗號表示單元素元組:``a,`` 或 ``(a,)``" -#: ../../library/stdtypes.rst:1464 +#: ../../library/stdtypes.rst:1567 msgid "Separating items with commas: ``a, b, c`` or ``(a, b, c)``" msgstr "使用逗號分隔項目:``a, b, c`` 或 ``(a, b, c)``" -#: ../../library/stdtypes.rst:1465 +#: ../../library/stdtypes.rst:1568 msgid "Using the :func:`tuple` built-in: ``tuple()`` or ``tuple(iterable)``" msgstr "" -#: ../../library/stdtypes.rst:1467 +#: ../../library/stdtypes.rst:1570 msgid "" "The constructor builds a tuple whose items are the same and in the same " "order as *iterable*'s items. *iterable* may be either a sequence, a " @@ -2298,7 +2446,7 @@ msgid "" "``()``." msgstr "" -#: ../../library/stdtypes.rst:1475 +#: ../../library/stdtypes.rst:1578 msgid "" "Note that it is actually the comma which makes a tuple, not the parentheses. " "The parentheses are optional, except in the empty tuple case, or when they " @@ -2307,30 +2455,30 @@ msgid "" "call with a 3-tuple as the sole argument." msgstr "" -#: ../../library/stdtypes.rst:1481 +#: ../../library/stdtypes.rst:1584 msgid "" "Tuples implement all of the :ref:`common ` sequence " "operations." msgstr "" -#: ../../library/stdtypes.rst:1484 +#: ../../library/stdtypes.rst:1587 msgid "" "For heterogeneous collections of data where access by name is clearer than " "access by index, :func:`collections.namedtuple` may be a more appropriate " "choice than a simple tuple object." msgstr "" -#: ../../library/stdtypes.rst:1492 +#: ../../library/stdtypes.rst:1595 msgid "Ranges" msgstr "" -#: ../../library/stdtypes.rst:1496 +#: ../../library/stdtypes.rst:1599 msgid "" "The :class:`range` type represents an immutable sequence of numbers and is " "commonly used for looping a specific number of times in :keyword:`for` loops." msgstr "" -#: ../../library/stdtypes.rst:1503 +#: ../../library/stdtypes.rst:1606 msgid "" "The arguments to the range constructor must be integers (either built-in :" "class:`int` or any object that implements the :meth:`~object.__index__` " @@ -2339,38 +2487,38 @@ msgid "" "zero, :exc:`ValueError` is raised." msgstr "" -#: ../../library/stdtypes.rst:1509 +#: ../../library/stdtypes.rst:1612 msgid "" "For a positive *step*, the contents of a range ``r`` are determined by the " "formula ``r[i] = start + step*i`` where ``i >= 0`` and ``r[i] < stop``." msgstr "" -#: ../../library/stdtypes.rst:1513 +#: ../../library/stdtypes.rst:1616 msgid "" "For a negative *step*, the contents of the range are still determined by the " "formula ``r[i] = start + step*i``, but the constraints are ``i >= 0`` and " "``r[i] > stop``." msgstr "" -#: ../../library/stdtypes.rst:1517 +#: ../../library/stdtypes.rst:1620 msgid "" "A range object will be empty if ``r[0]`` does not meet the value constraint. " "Ranges do support negative indices, but these are interpreted as indexing " "from the end of the sequence determined by the positive indices." msgstr "" -#: ../../library/stdtypes.rst:1522 +#: ../../library/stdtypes.rst:1625 msgid "" "Ranges containing absolute values larger than :data:`sys.maxsize` are " "permitted but some features (such as :func:`len`) may raise :exc:" "`OverflowError`." msgstr "" -#: ../../library/stdtypes.rst:1526 +#: ../../library/stdtypes.rst:1629 msgid "Range examples::" msgstr "" -#: ../../library/stdtypes.rst:1528 +#: ../../library/stdtypes.rst:1631 msgid "" ">>> list(range(10))\n" "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" @@ -2402,7 +2550,7 @@ msgstr "" ">>> list(range(1, 0))\n" "[]" -#: ../../library/stdtypes.rst:1543 +#: ../../library/stdtypes.rst:1646 msgid "" "Ranges implement all of the :ref:`common ` sequence " "operations except concatenation and repetition (due to the fact that range " @@ -2410,23 +2558,23 @@ msgid "" "repetition and concatenation will usually violate that pattern)." msgstr "" -#: ../../library/stdtypes.rst:1550 +#: ../../library/stdtypes.rst:1653 msgid "" "The value of the *start* parameter (or ``0`` if the parameter was not " "supplied)" msgstr "" -#: ../../library/stdtypes.rst:1555 +#: ../../library/stdtypes.rst:1658 msgid "The value of the *stop* parameter" msgstr "" -#: ../../library/stdtypes.rst:1559 +#: ../../library/stdtypes.rst:1662 msgid "" "The value of the *step* parameter (or ``1`` if the parameter was not " "supplied)" msgstr "" -#: ../../library/stdtypes.rst:1562 +#: ../../library/stdtypes.rst:1665 msgid "" "The advantage of the :class:`range` type over a regular :class:`list` or :" "class:`tuple` is that a :class:`range` object will always take the same " @@ -2435,14 +2583,14 @@ msgid "" "individual items and subranges as needed)." msgstr "" -#: ../../library/stdtypes.rst:1568 +#: ../../library/stdtypes.rst:1671 msgid "" "Range objects implement the :class:`collections.abc.Sequence` ABC, and " "provide features such as containment tests, element index lookup, slicing " "and support for negative indices (see :ref:`typesseq`):" msgstr "" -#: ../../library/stdtypes.rst:1588 +#: ../../library/stdtypes.rst:1691 msgid "" "Testing range objects for equality with ``==`` and ``!=`` compares them as " "sequences. That is, two range objects are considered equal if they " @@ -2452,489 +2600,489 @@ msgid "" "3)`` or ``range(0, 3, 2) == range(0, 4, 2)``.)" msgstr "" -#: ../../library/stdtypes.rst:1595 +#: ../../library/stdtypes.rst:1698 msgid "" "Implement the Sequence ABC. Support slicing and negative indices. Test :" "class:`int` objects for membership in constant time instead of iterating " "through all items." msgstr "" -#: ../../library/stdtypes.rst:1601 +#: ../../library/stdtypes.rst:1704 msgid "" "Define '==' and '!=' to compare range objects based on the sequence of " "values they define (instead of comparing based on object identity)." msgstr "" -#: ../../library/stdtypes.rst:1606 +#: ../../library/stdtypes.rst:1709 msgid "" "Added the :attr:`~range.start`, :attr:`~range.stop` and :attr:`~range.step` " "attributes." msgstr "" -#: ../../library/stdtypes.rst:1611 +#: ../../library/stdtypes.rst:1714 msgid "" "The `linspace recipe `_ shows how to implement a lazy version of range " "suitable for floating-point applications." msgstr "" -#: ../../library/stdtypes.rst:1623 +#: ../../library/stdtypes.rst:1726 msgid "Text and Binary Sequence Type Methods Summary" msgstr "" -#: ../../library/stdtypes.rst:1624 +#: ../../library/stdtypes.rst:1727 msgid "" "The following table summarizes the text and binary sequence types methods by " "category." msgstr "" -#: ../../library/stdtypes.rst:1629 +#: ../../library/stdtypes.rst:1732 msgid "Category" msgstr "分類" -#: ../../library/stdtypes.rst:1629 +#: ../../library/stdtypes.rst:1732 msgid ":class:`str` methods" msgstr ":class:`str` 方法" -#: ../../library/stdtypes.rst:1629 +#: ../../library/stdtypes.rst:1732 msgid ":class:`bytes` and :class:`bytearray` methods" msgstr ":class:`bytes` 和 :class:`bytearray` 方法" -#: ../../library/stdtypes.rst:1631 +#: ../../library/stdtypes.rst:1734 msgid "Formatting" msgstr "格式化" -#: ../../library/stdtypes.rst:1631 +#: ../../library/stdtypes.rst:1734 msgid ":meth:`str.format`" msgstr ":meth:`str.format`" -#: ../../library/stdtypes.rst:1633 +#: ../../library/stdtypes.rst:1736 msgid ":meth:`str.format_map`" msgstr ":meth:`str.format_map`" -#: ../../library/stdtypes.rst:1635 +#: ../../library/stdtypes.rst:1738 msgid ":ref:`f-strings`" msgstr ":ref:`f-strings`" -#: ../../library/stdtypes.rst:1637 +#: ../../library/stdtypes.rst:1740 msgid ":ref:`old-string-formatting`" msgstr ":ref:`old-string-formatting`" -#: ../../library/stdtypes.rst:1637 +#: ../../library/stdtypes.rst:1740 msgid ":ref:`bytes-formatting`" msgstr ":ref:`bytes-formatting`" -#: ../../library/stdtypes.rst:1639 +#: ../../library/stdtypes.rst:1742 msgid "Searching and Replacing" msgstr "搜尋和取代" -#: ../../library/stdtypes.rst:1639 +#: ../../library/stdtypes.rst:1742 msgid ":meth:`str.find`" msgstr ":meth:`str.find`" -#: ../../library/stdtypes.rst:1639 +#: ../../library/stdtypes.rst:1742 msgid ":meth:`str.rfind`" msgstr ":meth:`str.rfind`" -#: ../../library/stdtypes.rst:1639 +#: ../../library/stdtypes.rst:1742 msgid ":meth:`bytes.find`" msgstr ":meth:`bytes.find`" -#: ../../library/stdtypes.rst:1639 +#: ../../library/stdtypes.rst:1742 msgid ":meth:`bytes.rfind`" msgstr ":meth:`bytes.rfind`" -#: ../../library/stdtypes.rst:1641 +#: ../../library/stdtypes.rst:1744 msgid ":meth:`str.index`" msgstr ":meth:`str.index`" -#: ../../library/stdtypes.rst:1641 +#: ../../library/stdtypes.rst:1744 msgid ":meth:`str.rindex`" msgstr ":meth:`str.rindex`" -#: ../../library/stdtypes.rst:1641 +#: ../../library/stdtypes.rst:1744 msgid ":meth:`bytes.index`" msgstr ":meth:`bytes.index`" -#: ../../library/stdtypes.rst:1641 +#: ../../library/stdtypes.rst:1744 msgid ":meth:`bytes.rindex`" msgstr ":meth:`bytes.rindex`" -#: ../../library/stdtypes.rst:1643 +#: ../../library/stdtypes.rst:1746 msgid ":meth:`str.startswith`" msgstr ":meth:`str.startswith`" -#: ../../library/stdtypes.rst:1643 +#: ../../library/stdtypes.rst:1746 msgid ":meth:`bytes.startswith`" msgstr ":meth:`bytes.startswith`" -#: ../../library/stdtypes.rst:1645 +#: ../../library/stdtypes.rst:1748 msgid ":meth:`str.endswith`" msgstr ":meth:`str.endswith`" -#: ../../library/stdtypes.rst:1645 +#: ../../library/stdtypes.rst:1748 msgid ":meth:`bytes.endswith`" msgstr ":meth:`bytes.endswith`" -#: ../../library/stdtypes.rst:1647 +#: ../../library/stdtypes.rst:1750 msgid ":meth:`str.count`" msgstr ":meth:`str.count`" -#: ../../library/stdtypes.rst:1647 +#: ../../library/stdtypes.rst:1750 msgid ":meth:`bytes.count`" msgstr ":meth:`bytes.count`" -#: ../../library/stdtypes.rst:1649 +#: ../../library/stdtypes.rst:1752 msgid ":meth:`str.replace`" msgstr ":meth:`str.replace`" -#: ../../library/stdtypes.rst:1649 +#: ../../library/stdtypes.rst:1752 msgid ":meth:`bytes.replace`" msgstr ":meth:`bytes.replace`" -#: ../../library/stdtypes.rst:1651 +#: ../../library/stdtypes.rst:1754 msgid "Splitting and Joining" msgstr "分割和連接" -#: ../../library/stdtypes.rst:1651 +#: ../../library/stdtypes.rst:1754 msgid ":meth:`str.split`" msgstr ":meth:`str.split`" -#: ../../library/stdtypes.rst:1651 +#: ../../library/stdtypes.rst:1754 msgid ":meth:`str.rsplit`" msgstr ":meth:`str.rsplit`" -#: ../../library/stdtypes.rst:1651 +#: ../../library/stdtypes.rst:1754 msgid ":meth:`bytes.split`" msgstr ":meth:`bytes.split`" -#: ../../library/stdtypes.rst:1651 +#: ../../library/stdtypes.rst:1754 msgid ":meth:`bytes.rsplit`" msgstr ":meth:`bytes.rsplit`" -#: ../../library/stdtypes.rst:1653 +#: ../../library/stdtypes.rst:1756 msgid ":meth:`str.splitlines`" msgstr ":meth:`str.splitlines`" -#: ../../library/stdtypes.rst:1653 +#: ../../library/stdtypes.rst:1756 msgid ":meth:`bytes.splitlines`" msgstr ":meth:`bytes.splitlines`" -#: ../../library/stdtypes.rst:1655 +#: ../../library/stdtypes.rst:1758 msgid ":meth:`str.partition`" msgstr ":meth:`str.partition`" -#: ../../library/stdtypes.rst:1655 +#: ../../library/stdtypes.rst:1758 msgid ":meth:`bytes.partition`" msgstr ":meth:`bytes.partition`" -#: ../../library/stdtypes.rst:1657 +#: ../../library/stdtypes.rst:1760 msgid ":meth:`str.rpartition`" msgstr ":meth:`str.rpartition`" -#: ../../library/stdtypes.rst:1657 +#: ../../library/stdtypes.rst:1760 msgid ":meth:`bytes.rpartition`" msgstr ":meth:`bytes.rpartition`" -#: ../../library/stdtypes.rst:1659 +#: ../../library/stdtypes.rst:1762 msgid ":meth:`str.join`" msgstr ":meth:`str.join`" -#: ../../library/stdtypes.rst:1659 +#: ../../library/stdtypes.rst:1762 msgid ":meth:`bytes.join`" msgstr ":meth:`bytes.join`" -#: ../../library/stdtypes.rst:1661 +#: ../../library/stdtypes.rst:1764 msgid "String Classification" msgstr "字串分類" -#: ../../library/stdtypes.rst:1661 +#: ../../library/stdtypes.rst:1764 msgid ":meth:`str.isalpha`" msgstr ":meth:`str.isalpha`" -#: ../../library/stdtypes.rst:1661 +#: ../../library/stdtypes.rst:1764 msgid ":meth:`bytes.isalpha`" msgstr ":meth:`bytes.isalpha`" -#: ../../library/stdtypes.rst:1663 +#: ../../library/stdtypes.rst:1766 msgid ":meth:`str.isdecimal`" msgstr ":meth:`str.isdecimal`" -#: ../../library/stdtypes.rst:1665 +#: ../../library/stdtypes.rst:1768 msgid ":meth:`str.isdigit`" msgstr ":meth:`str.isdigit`" -#: ../../library/stdtypes.rst:1665 +#: ../../library/stdtypes.rst:1768 msgid ":meth:`bytes.isdigit`" msgstr ":meth:`bytes.isdigit`" -#: ../../library/stdtypes.rst:1667 +#: ../../library/stdtypes.rst:1770 msgid ":meth:`str.isnumeric`" msgstr ":meth:`str.isnumeric`" -#: ../../library/stdtypes.rst:1669 +#: ../../library/stdtypes.rst:1772 msgid ":meth:`str.isalnum`" msgstr ":meth:`str.isalnum`" -#: ../../library/stdtypes.rst:1669 +#: ../../library/stdtypes.rst:1772 msgid ":meth:`bytes.isalnum`" msgstr ":meth:`bytes.isalnum`" -#: ../../library/stdtypes.rst:1671 +#: ../../library/stdtypes.rst:1774 msgid ":meth:`str.isidentifier`" msgstr ":meth:`str.isidentifier`" -#: ../../library/stdtypes.rst:1673 +#: ../../library/stdtypes.rst:1776 msgid ":meth:`str.islower`" msgstr ":meth:`str.islower`" -#: ../../library/stdtypes.rst:1673 +#: ../../library/stdtypes.rst:1776 msgid ":meth:`bytes.islower`" msgstr ":meth:`bytes.islower`" -#: ../../library/stdtypes.rst:1675 +#: ../../library/stdtypes.rst:1778 msgid ":meth:`str.isupper`" msgstr ":meth:`str.isupper`" -#: ../../library/stdtypes.rst:1675 +#: ../../library/stdtypes.rst:1778 msgid ":meth:`bytes.isupper`" msgstr ":meth:`bytes.isupper`" -#: ../../library/stdtypes.rst:1677 +#: ../../library/stdtypes.rst:1780 msgid ":meth:`str.istitle`" msgstr ":meth:`str.istitle`" -#: ../../library/stdtypes.rst:1677 +#: ../../library/stdtypes.rst:1780 msgid ":meth:`bytes.istitle`" msgstr ":meth:`bytes.istitle`" -#: ../../library/stdtypes.rst:1679 +#: ../../library/stdtypes.rst:1782 msgid ":meth:`str.isspace`" msgstr ":meth:`str.isspace`" -#: ../../library/stdtypes.rst:1679 +#: ../../library/stdtypes.rst:1782 msgid ":meth:`bytes.isspace`" msgstr ":meth:`bytes.isspace`" -#: ../../library/stdtypes.rst:1681 +#: ../../library/stdtypes.rst:1784 msgid ":meth:`str.isprintable`" msgstr ":meth:`str.isprintable`" -#: ../../library/stdtypes.rst:1683 +#: ../../library/stdtypes.rst:1786 msgid "Case Manipulation" msgstr "大小寫操作" -#: ../../library/stdtypes.rst:1683 +#: ../../library/stdtypes.rst:1786 msgid ":meth:`str.lower`" msgstr ":meth:`str.lower`" -#: ../../library/stdtypes.rst:1683 +#: ../../library/stdtypes.rst:1786 msgid ":meth:`bytes.lower`" msgstr ":meth:`bytes.lower`" -#: ../../library/stdtypes.rst:1685 +#: ../../library/stdtypes.rst:1788 msgid ":meth:`str.upper`" msgstr ":meth:`str.upper`" -#: ../../library/stdtypes.rst:1685 +#: ../../library/stdtypes.rst:1788 msgid ":meth:`bytes.upper`" msgstr ":meth:`bytes.upper`" -#: ../../library/stdtypes.rst:1687 +#: ../../library/stdtypes.rst:1790 msgid ":meth:`str.casefold`" msgstr ":meth:`str.casefold`" -#: ../../library/stdtypes.rst:1689 +#: ../../library/stdtypes.rst:1792 msgid ":meth:`str.capitalize`" msgstr ":meth:`str.capitalize`" -#: ../../library/stdtypes.rst:1689 +#: ../../library/stdtypes.rst:1792 msgid ":meth:`bytes.capitalize`" msgstr ":meth:`bytes.capitalize`" -#: ../../library/stdtypes.rst:1691 +#: ../../library/stdtypes.rst:1794 msgid ":meth:`str.title`" msgstr ":meth:`str.title`" -#: ../../library/stdtypes.rst:1691 +#: ../../library/stdtypes.rst:1794 msgid ":meth:`bytes.title`" msgstr ":meth:`bytes.title`" -#: ../../library/stdtypes.rst:1693 +#: ../../library/stdtypes.rst:1796 msgid ":meth:`str.swapcase`" msgstr ":meth:`str.swapcase`" -#: ../../library/stdtypes.rst:1693 +#: ../../library/stdtypes.rst:1796 msgid ":meth:`bytes.swapcase`" msgstr ":meth:`bytes.swapcase`" -#: ../../library/stdtypes.rst:1695 +#: ../../library/stdtypes.rst:1798 msgid "Padding and Stripping" msgstr "填充和去除空白" -#: ../../library/stdtypes.rst:1695 +#: ../../library/stdtypes.rst:1798 msgid ":meth:`str.ljust`" msgstr ":meth:`str.ljust`" -#: ../../library/stdtypes.rst:1695 +#: ../../library/stdtypes.rst:1798 msgid ":meth:`str.rjust`" msgstr ":meth:`str.rjust`" -#: ../../library/stdtypes.rst:1695 +#: ../../library/stdtypes.rst:1798 msgid ":meth:`bytes.ljust`" msgstr ":meth:`bytes.ljust`" -#: ../../library/stdtypes.rst:1695 +#: ../../library/stdtypes.rst:1798 msgid ":meth:`bytes.rjust`" msgstr ":meth:`bytes.rjust`" -#: ../../library/stdtypes.rst:1697 +#: ../../library/stdtypes.rst:1800 msgid ":meth:`str.center`" msgstr ":meth:`str.center`" -#: ../../library/stdtypes.rst:1697 +#: ../../library/stdtypes.rst:1800 msgid ":meth:`bytes.center`" msgstr ":meth:`bytes.center`" -#: ../../library/stdtypes.rst:1699 +#: ../../library/stdtypes.rst:1802 msgid ":meth:`str.expandtabs`" msgstr ":meth:`str.expandtabs`" -#: ../../library/stdtypes.rst:1699 +#: ../../library/stdtypes.rst:1802 msgid ":meth:`bytes.expandtabs`" msgstr ":meth:`bytes.expandtabs`" -#: ../../library/stdtypes.rst:1701 +#: ../../library/stdtypes.rst:1804 msgid ":meth:`str.strip`" msgstr ":meth:`str.strip`" -#: ../../library/stdtypes.rst:1701 +#: ../../library/stdtypes.rst:1804 msgid ":meth:`bytes.strip`" msgstr ":meth:`bytes.strip`" -#: ../../library/stdtypes.rst:1703 +#: ../../library/stdtypes.rst:1806 msgid ":meth:`str.lstrip`" msgstr ":meth:`str.lstrip`" -#: ../../library/stdtypes.rst:1703 +#: ../../library/stdtypes.rst:1806 msgid ":meth:`str.rstrip`" msgstr ":meth:`str.rstrip`" -#: ../../library/stdtypes.rst:1703 +#: ../../library/stdtypes.rst:1806 msgid ":meth:`bytes.lstrip`" msgstr ":meth:`bytes.lstrip`" -#: ../../library/stdtypes.rst:1703 +#: ../../library/stdtypes.rst:1806 msgid ":meth:`bytes.rstrip`" msgstr ":meth:`bytes.rstrip`" -#: ../../library/stdtypes.rst:1705 +#: ../../library/stdtypes.rst:1808 msgid "Translation and Encoding" msgstr "翻譯和編碼" -#: ../../library/stdtypes.rst:1705 +#: ../../library/stdtypes.rst:1808 msgid ":meth:`str.translate`" msgstr ":meth:`str.translate`" -#: ../../library/stdtypes.rst:1705 +#: ../../library/stdtypes.rst:1808 msgid ":meth:`bytes.translate`" msgstr ":meth:`bytes.translate`" -#: ../../library/stdtypes.rst:1707 +#: ../../library/stdtypes.rst:1810 msgid ":meth:`str.maketrans`" msgstr ":meth:`str.maketrans`" -#: ../../library/stdtypes.rst:1707 +#: ../../library/stdtypes.rst:1810 msgid ":meth:`bytes.maketrans`" msgstr ":meth:`bytes.maketrans`" -#: ../../library/stdtypes.rst:1709 +#: ../../library/stdtypes.rst:1812 msgid ":meth:`str.encode`" msgstr ":meth:`str.encode`" -#: ../../library/stdtypes.rst:1711 +#: ../../library/stdtypes.rst:1814 msgid ":meth:`bytes.decode`" msgstr ":meth:`bytes.decode`" -#: ../../library/stdtypes.rst:1717 +#: ../../library/stdtypes.rst:1820 msgid "Text Sequence Type --- :class:`str`" msgstr "" -#: ../../library/stdtypes.rst:1719 +#: ../../library/stdtypes.rst:1822 msgid "" "Textual data in Python is handled with :class:`str` objects, or :dfn:" "`strings`. Strings are immutable :ref:`sequences ` of Unicode code " "points. String literals are written in a variety of ways:" msgstr "" -#: ../../library/stdtypes.rst:1724 +#: ../../library/stdtypes.rst:1827 msgid "Single quotes: ``'allows embedded \"double\" quotes'``" msgstr "" -#: ../../library/stdtypes.rst:1725 +#: ../../library/stdtypes.rst:1828 msgid "Double quotes: ``\"allows embedded 'single' quotes\"``" msgstr "" -#: ../../library/stdtypes.rst:1726 +#: ../../library/stdtypes.rst:1829 msgid "" "Triple quoted: ``'''Three single quotes'''``, ``\"\"\"Three double " "quotes\"\"\"``" msgstr "" -#: ../../library/stdtypes.rst:1728 +#: ../../library/stdtypes.rst:1831 msgid "" "Triple quoted strings may span multiple lines - all associated whitespace " "will be included in the string literal." msgstr "" -#: ../../library/stdtypes.rst:1731 +#: ../../library/stdtypes.rst:1834 msgid "" "String literals that are part of a single expression and have only " "whitespace between them will be implicitly converted to a single string " "literal. That is, ``(\"spam \" \"eggs\") == \"spam eggs\"``." msgstr "" -#: ../../library/stdtypes.rst:1735 +#: ../../library/stdtypes.rst:1838 msgid "" "See :ref:`strings` for more about the various forms of string literal, " "including supported :ref:`escape sequences `, and the " "``r`` (\"raw\") prefix that disables most escape sequence processing." msgstr "" -#: ../../library/stdtypes.rst:1739 +#: ../../library/stdtypes.rst:1842 msgid "" "Strings may also be created from other objects using the :class:`str` " "constructor." msgstr "" -#: ../../library/stdtypes.rst:1742 +#: ../../library/stdtypes.rst:1845 msgid "" "Since there is no separate \"character\" type, indexing a string produces " "strings of length 1. That is, for a non-empty string *s*, ``s[0] == s[0:1]``." msgstr "" -#: ../../library/stdtypes.rst:1748 +#: ../../library/stdtypes.rst:1851 msgid "" "There is also no mutable string type, but :meth:`str.join` or :class:`io." "StringIO` can be used to efficiently construct strings from multiple " "fragments." msgstr "" -#: ../../library/stdtypes.rst:1752 +#: ../../library/stdtypes.rst:1855 msgid "" "For backwards compatibility with the Python 2 series, the ``u`` prefix is " "once again permitted on string literals. It has no effect on the meaning of " "string literals and cannot be combined with the ``r`` prefix." msgstr "" -#: ../../library/stdtypes.rst:1766 +#: ../../library/stdtypes.rst:1869 msgid "" "Return a :ref:`string ` version of *object*. If *object* is not " "provided, returns the empty string. Otherwise, the behavior of ``str()`` " "depends on whether *encoding* or *errors* is given, as follows." msgstr "" -#: ../../library/stdtypes.rst:1770 +#: ../../library/stdtypes.rst:1873 msgid "" "If neither *encoding* nor *errors* is given, ``str(object)`` returns :meth:" "`type(object).__str__(object) `, which is the \"informal\" " @@ -2944,7 +3092,7 @@ msgid "" "`repr(object) `." msgstr "" -#: ../../library/stdtypes.rst:1782 +#: ../../library/stdtypes.rst:1885 msgid "" "If at least one of *encoding* or *errors* is given, *object* should be a :" "term:`bytes-like object` (e.g. :class:`bytes` or :class:`bytearray`). In " @@ -2956,7 +3104,7 @@ msgid "" "buffer objects." msgstr "" -#: ../../library/stdtypes.rst:1791 +#: ../../library/stdtypes.rst:1894 msgid "" "Passing a :class:`bytes` object to :func:`str` without the *encoding* or " "*errors* arguments falls under the first case of returning the informal " @@ -2964,7 +3112,7 @@ msgid "" "Python). For example::" msgstr "" -#: ../../library/stdtypes.rst:1796 +#: ../../library/stdtypes.rst:1899 msgid "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" @@ -2972,7 +3120,7 @@ msgstr "" ">>> str(b'Zoot!')\n" "\"b'Zoot!'\"" -#: ../../library/stdtypes.rst:1799 +#: ../../library/stdtypes.rst:1902 msgid "" "For more information on the ``str`` class and its methods, see :ref:" "`textseq` and the :ref:`string-methods` section below. To output formatted " @@ -2980,17 +3128,17 @@ msgid "" "addition, see the :ref:`stringservices` section." msgstr "" -#: ../../library/stdtypes.rst:1811 +#: ../../library/stdtypes.rst:1914 msgid "String Methods" msgstr "字串方法" -#: ../../library/stdtypes.rst:1816 +#: ../../library/stdtypes.rst:1919 msgid "" "Strings implement all of the :ref:`common ` sequence " "operations, along with the additional methods described below." msgstr "" -#: ../../library/stdtypes.rst:1819 +#: ../../library/stdtypes.rst:1922 msgid "" "Strings also support two styles of string formatting, one providing a large " "degree of flexibility and customization (see :meth:`str.format`, :ref:" @@ -3000,33 +3148,33 @@ msgid "" "handle (:ref:`old-string-formatting`)." msgstr "" -#: ../../library/stdtypes.rst:1826 +#: ../../library/stdtypes.rst:1929 msgid "" "The :ref:`textservices` section of the standard library covers a number of " "other modules that provide various text related utilities (including regular " "expression support in the :mod:`re` module)." msgstr "" -#: ../../library/stdtypes.rst:1832 +#: ../../library/stdtypes.rst:1935 msgid "" "Return a copy of the string with its first character capitalized and the " "rest lowercased." msgstr "" -#: ../../library/stdtypes.rst:1835 +#: ../../library/stdtypes.rst:1938 msgid "" "The first character is now put into titlecase rather than uppercase. This " "means that characters like digraphs will only have their first letter " "capitalized, instead of the full character." msgstr "" -#: ../../library/stdtypes.rst:1842 +#: ../../library/stdtypes.rst:1945 msgid "" "Return a casefolded copy of the string. Casefolded strings may be used for " "caseless matching." msgstr "" -#: ../../library/stdtypes.rst:1845 +#: ../../library/stdtypes.rst:1948 msgid "" "Casefolding is similar to lowercasing but more aggressive because it is " "intended to remove all case distinctions in a string. For example, the " @@ -3035,7 +3183,7 @@ msgid "" "`casefold` converts it to ``\"ss\"``. For example:" msgstr "" -#: ../../library/stdtypes.rst:1852 +#: ../../library/stdtypes.rst:1955 msgid "" ">>> 'straße'.lower()\n" "'straße'\n" @@ -3047,21 +3195,21 @@ msgstr "" ">>> 'straße'.casefold()\n" "'strasse'" -#: ../../library/stdtypes.rst:1859 +#: ../../library/stdtypes.rst:1962 msgid "" "The casefolding algorithm is `described in section 3.13 'Default Case " "Folding' of the Unicode Standard `__." msgstr "" -#: ../../library/stdtypes.rst:1868 +#: ../../library/stdtypes.rst:1971 msgid "" "Return centered in a string of length *width*. Padding is done using the " "specified *fillchar* (default is an ASCII space). The original string is " "returned if *width* is less than or equal to ``len(s)``. For example::" msgstr "" -#: ../../library/stdtypes.rst:1872 +#: ../../library/stdtypes.rst:1975 msgid "" ">>> 'Python'.center(10)\n" "' Python '\n" @@ -3077,20 +3225,20 @@ msgstr "" ">>> 'Python'.center(4)\n" "'Python'" -#: ../../library/stdtypes.rst:1882 +#: ../../library/stdtypes.rst:1985 msgid "" "Return the number of non-overlapping occurrences of substring *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../library/stdtypes.rst:1886 +#: ../../library/stdtypes.rst:1989 msgid "" "If *sub* is empty, returns the number of empty strings between characters " "which is the length of the string plus one. For example::" msgstr "" -#: ../../library/stdtypes.rst:1889 +#: ../../library/stdtypes.rst:1992 msgid "" ">>> 'spam, spam, spam'.count('spam')\n" "3\n" @@ -3114,17 +3262,17 @@ msgstr "" ">>> 'spam, spam, spam'.count('')\n" "17" -#: ../../library/stdtypes.rst:1902 +#: ../../library/stdtypes.rst:2005 msgid "Return the string encoded to :class:`bytes`." msgstr "" -#: ../../library/stdtypes.rst:1904 ../../library/stdtypes.rst:3447 +#: ../../library/stdtypes.rst:2007 ../../library/stdtypes.rst:3550 msgid "" "*encoding* defaults to ``'utf-8'``; see :ref:`standard-encodings` for " "possible values." msgstr "" -#: ../../library/stdtypes.rst:1907 +#: ../../library/stdtypes.rst:2010 msgid "" "*errors* controls how encoding errors are handled. If ``'strict'`` (the " "default), a :exc:`UnicodeError` exception is raised. Other possible values " @@ -3133,14 +3281,14 @@ msgid "" "register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../library/stdtypes.rst:1914 +#: ../../library/stdtypes.rst:2017 msgid "" "For performance reasons, the value of *errors* is not checked for validity " "unless an encoding error actually occurs, :ref:`devmode` is enabled or a :" "ref:`debug build ` is used. For example::" msgstr "" -#: ../../library/stdtypes.rst:1920 +#: ../../library/stdtypes.rst:2023 msgid "" ">>> encoded_str_to_bytes = 'Python'.encode()\n" ">>> type(encoded_str_to_bytes)\n" @@ -3154,17 +3302,17 @@ msgstr "" ">>> encoded_str_to_bytes\n" "b'Python'" -#: ../../library/stdtypes.rst:1927 ../../library/stdtypes.rst:3466 +#: ../../library/stdtypes.rst:2030 ../../library/stdtypes.rst:3569 msgid "Added support for keyword arguments." msgstr "新增關鍵字引數的支援。" -#: ../../library/stdtypes.rst:1930 ../../library/stdtypes.rst:3469 +#: ../../library/stdtypes.rst:2033 ../../library/stdtypes.rst:3572 msgid "" "The value of the *errors* argument is now checked in :ref:`devmode` and in :" "ref:`debug mode `." msgstr "" -#: ../../library/stdtypes.rst:1937 +#: ../../library/stdtypes.rst:2040 msgid "" "Return ``True`` if the string ends with the specified *suffix*, otherwise " "return ``False``. *suffix* can also be a tuple of suffixes to look for. " @@ -3173,7 +3321,7 @@ msgid "" "equivalent to ``str[start:end].endswith(suffix)``. For example::" msgstr "" -#: ../../library/stdtypes.rst:1943 +#: ../../library/stdtypes.rst:2046 msgid "" ">>> 'Python'.endswith('on')\n" "True\n" @@ -3193,11 +3341,11 @@ msgstr "" ">>> 'Python is amazing'.endswith('is', 0, 9)\n" "True" -#: ../../library/stdtypes.rst:1952 +#: ../../library/stdtypes.rst:2055 msgid "See also :meth:`startswith` and :meth:`removesuffix`." msgstr "另請參閱 :meth:`startswith` 和 :meth:`removesuffix`。" -#: ../../library/stdtypes.rst:1957 +#: ../../library/stdtypes.rst:2060 msgid "" "Return a copy of the string where all tab characters are replaced by one or " "more spaces, depending on the current column and the given tab size. Tab " @@ -3213,7 +3361,7 @@ msgid "" "printed. For example::" msgstr "" -#: ../../library/stdtypes.rst:1970 +#: ../../library/stdtypes.rst:2073 msgid "" ">>> '01\\t012\\t0123\\t01234'.expandtabs()\n" "'01 012 0123 01234'\n" @@ -3231,7 +3379,7 @@ msgstr "" "01 012\n" "0123 01234" -#: ../../library/stdtypes.rst:1981 +#: ../../library/stdtypes.rst:2084 msgid "" "Return the lowest index in the string where substring *sub* is found within " "the slice ``s[start:end]``. Optional arguments *start* and *end* are " @@ -3239,7 +3387,7 @@ msgid "" "example::" msgstr "" -#: ../../library/stdtypes.rst:1986 +#: ../../library/stdtypes.rst:2089 msgid "" ">>> 'spam, spam, spam'.find('sp')\n" "0\n" @@ -3251,18 +3399,18 @@ msgstr "" ">>> 'spam, spam, spam'.find('sp', 5)\n" "6" -#: ../../library/stdtypes.rst:1991 +#: ../../library/stdtypes.rst:2094 msgid "See also :meth:`rfind` and :meth:`index`." msgstr "另請參閱 :meth:`rfind` 和 :meth:`index`。" -#: ../../library/stdtypes.rst:1995 +#: ../../library/stdtypes.rst:2098 msgid "" "The :meth:`~str.find` method should be used only if you need to know the " "position of *sub*. To check if *sub* is a substring or not, use the :" "keyword:`in` operator::" msgstr "" -#: ../../library/stdtypes.rst:1999 +#: ../../library/stdtypes.rst:2102 msgid "" ">>> 'Py' in 'Python'\n" "True" @@ -3270,7 +3418,7 @@ msgstr "" ">>> 'Py' in 'Python'\n" "True" -#: ../../library/stdtypes.rst:2005 +#: ../../library/stdtypes.rst:2108 msgid "" "Perform a string formatting operation. The string on which this method is " "called can contain literal text or replacement fields delimited by braces " @@ -3280,7 +3428,7 @@ msgid "" "the corresponding argument. For example:" msgstr "" -#: ../../library/stdtypes.rst:2012 +#: ../../library/stdtypes.rst:2115 msgid "" ">>> \"The sum of 1 + 2 is {0}\".format(1+2)\n" "'The sum of 1 + 2 is 3'\n" @@ -3290,13 +3438,13 @@ msgid "" "'Nobody expects the Spanish Inquisition!'" msgstr "" -#: ../../library/stdtypes.rst:2021 +#: ../../library/stdtypes.rst:2124 msgid "" "See :ref:`formatstrings` for a description of the various formatting options " "that can be specified in format strings." msgstr "" -#: ../../library/stdtypes.rst:2025 +#: ../../library/stdtypes.rst:2128 msgid "" "When formatting a number (:class:`int`, :class:`float`, :class:`complex`, :" "class:`decimal.Decimal` and subclasses) with the ``n`` type (ex: ``'{:n}'." @@ -3307,26 +3455,26 @@ msgid "" "This temporary change affects other threads." msgstr "" -#: ../../library/stdtypes.rst:2034 +#: ../../library/stdtypes.rst:2137 msgid "" "When formatting a number with the ``n`` type, the function sets temporarily " "the ``LC_CTYPE`` locale to the ``LC_NUMERIC`` locale in some cases." msgstr "" -#: ../../library/stdtypes.rst:2042 +#: ../../library/stdtypes.rst:2145 msgid "" "Similar to ``str.format(**mapping)``, except that ``mapping`` is used " "directly and not copied to a :class:`dict`. This is useful if for example " "``mapping`` is a dict subclass:" msgstr "" -#: ../../library/stdtypes.rst:2058 +#: ../../library/stdtypes.rst:2161 msgid "" "Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is " "not found. For example:" msgstr "" -#: ../../library/stdtypes.rst:2061 +#: ../../library/stdtypes.rst:2164 msgid "" ">>> 'spam, spam, spam'.index('eggs')\n" "Traceback (most recent call last):\n" @@ -3342,11 +3490,11 @@ msgstr "" " ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n" "ValueError: substring not found" -#: ../../library/stdtypes.rst:2070 +#: ../../library/stdtypes.rst:2173 msgid "See also :meth:`rindex`." msgstr "另請參閱 :meth:`rindex`。" -#: ../../library/stdtypes.rst:2075 +#: ../../library/stdtypes.rst:2178 msgid "" "Return ``True`` if all characters in the string are alphanumeric and there " "is at least one character, ``False`` otherwise. A character ``c`` is " @@ -3354,7 +3502,7 @@ msgid "" "isdecimal()``, ``c.isdigit()``, or ``c.isnumeric()``." msgstr "" -#: ../../library/stdtypes.rst:2083 +#: ../../library/stdtypes.rst:2186 msgid "" "Return ``True`` if all characters in the string are alphabetic and there is " "at least one character, ``False`` otherwise. Alphabetic characters are " @@ -3366,7 +3514,7 @@ msgid "" "spec/chapter-4/#G91002>`_. For example:" msgstr "" -#: ../../library/stdtypes.rst:2092 +#: ../../library/stdtypes.rst:2195 msgid "" ">>> 'Letters and spaces'.isalpha()\n" "False\n" @@ -3383,18 +3531,18 @@ msgstr "" ">>> 'µ'.isalpha() # 非 ASCII 字元也可以被視為字母\n" "True" -#: ../../library/stdtypes.rst:2101 +#: ../../library/stdtypes.rst:2204 msgid "See :ref:`unicode-properties`." msgstr "請參閱 :ref:`unicode-properties`。" -#: ../../library/stdtypes.rst:2106 +#: ../../library/stdtypes.rst:2209 msgid "" "Return ``True`` if the string is empty or all characters in the string are " "ASCII, ``False`` otherwise. ASCII characters have code points in the range " "U+0000-U+007F. For example:" msgstr "" -#: ../../library/stdtypes.rst:2110 +#: ../../library/stdtypes.rst:2213 msgid "" ">>> 'ASCII characters'.isascii()\n" "True\n" @@ -3406,7 +3554,7 @@ msgstr "" ">>> 'µ'.isascii()\n" "False" -#: ../../library/stdtypes.rst:2122 +#: ../../library/stdtypes.rst:2225 msgid "" "Return ``True`` if all characters in the string are decimal characters and " "there is at least one character, ``False`` otherwise. Decimal characters are " @@ -3415,7 +3563,7 @@ msgid "" "Unicode General Category \"Nd\". For example:" msgstr "" -#: ../../library/stdtypes.rst:2129 +#: ../../library/stdtypes.rst:2232 msgid "" ">>> '0123456789'.isdecimal()\n" "True\n" @@ -3431,7 +3579,7 @@ msgstr "" ">>> 'alphabetic'.isdecimal()\n" "False" -#: ../../library/stdtypes.rst:2141 +#: ../../library/stdtypes.rst:2244 msgid "" "Return ``True`` if all characters in the string are digits and there is at " "least one character, ``False`` otherwise. Digits include decimal characters " @@ -3441,23 +3589,23 @@ msgid "" "property value Numeric_Type=Digit or Numeric_Type=Decimal." msgstr "" -#: ../../library/stdtypes.rst:2151 +#: ../../library/stdtypes.rst:2254 msgid "" "Return ``True`` if the string is a valid identifier according to the " "language definition, section :ref:`identifiers`." msgstr "" -#: ../../library/stdtypes.rst:2154 +#: ../../library/stdtypes.rst:2257 msgid "" ":func:`keyword.iskeyword` can be used to test whether string ``s`` is a " "reserved identifier, such as :keyword:`def` and :keyword:`class`." msgstr "" -#: ../../library/stdtypes.rst:2157 +#: ../../library/stdtypes.rst:2260 msgid "Example: ::" msgstr "範例: ::" -#: ../../library/stdtypes.rst:2160 +#: ../../library/stdtypes.rst:2263 msgid "" ">>> from keyword import iskeyword\n" "\n" @@ -3473,13 +3621,13 @@ msgstr "" ">>> 'def'.isidentifier(), iskeyword('def')\n" "(True, True)" -#: ../../library/stdtypes.rst:2170 +#: ../../library/stdtypes.rst:2273 msgid "" "Return ``True`` if all cased characters [4]_ in the string are lowercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:2176 +#: ../../library/stdtypes.rst:2279 msgid "" "Return ``True`` if all characters in the string are numeric characters, and " "there is at least one character, ``False`` otherwise. Numeric characters " @@ -3489,7 +3637,7 @@ msgid "" "Numeric_Type=Decimal or Numeric_Type=Numeric. For example:" msgstr "" -#: ../../library/stdtypes.rst:2184 +#: ../../library/stdtypes.rst:2287 msgid "" ">>> '0123456789'.isnumeric()\n" "True\n" @@ -3509,19 +3657,20 @@ msgstr "" ">>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()\n" "(False, True, True)" -#: ../../library/stdtypes.rst:2195 +#: ../../library/stdtypes.rst:2298 msgid "" "See also :meth:`isdecimal` and :meth:`isdigit`. Numeric characters are a " "superset of decimal numbers." -msgstr "也請參閱 :meth:`isdecimal` 和 :meth:`isdigit`。數字字元是十進位數字的超集。" +msgstr "" +"也請參閱 :meth:`isdecimal` 和 :meth:`isdigit`。數字字元是十進位數字的超集。" -#: ../../library/stdtypes.rst:2201 +#: ../../library/stdtypes.rst:2304 msgid "" "Return ``True`` if all characters in the string are printable, ``False`` if " "it contains at least one non-printable character." msgstr "" -#: ../../library/stdtypes.rst:2204 +#: ../../library/stdtypes.rst:2307 msgid "" "Here \"printable\" means the character is suitable for :func:`repr` to use " "in its output; \"non-printable\" means that :func:`repr` on built-in types " @@ -3529,7 +3678,7 @@ msgid "" "written to :data:`sys.stdout` or :data:`sys.stderr`." msgstr "" -#: ../../library/stdtypes.rst:2209 +#: ../../library/stdtypes.rst:2312 msgid "" "The printable characters are those which in the Unicode character database " "(see :mod:`unicodedata`) have a general category in group Letter, Mark, " @@ -3538,12 +3687,12 @@ msgid "" "C), except the ASCII space." msgstr "" -#: ../../library/stdtypes.rst:2215 ../../library/stdtypes.rst:2242 -#: ../../library/stdtypes.rst:2297 +#: ../../library/stdtypes.rst:2318 ../../library/stdtypes.rst:2345 +#: ../../library/stdtypes.rst:2400 msgid "For example:" msgstr "舉例來說:" -#: ../../library/stdtypes.rst:2217 +#: ../../library/stdtypes.rst:2320 msgid "" ">>> ''.isprintable(), ' '.isprintable()\n" "(True, True)\n" @@ -3555,20 +3704,20 @@ msgstr "" ">>> '\\t'.isprintable(), '\\n'.isprintable()\n" "(False, False)" -#: ../../library/stdtypes.rst:2227 +#: ../../library/stdtypes.rst:2330 msgid "" "Return ``True`` if there are only whitespace characters in the string and " "there is at least one character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:2230 +#: ../../library/stdtypes.rst:2333 msgid "" "A character is *whitespace* if in the Unicode character database (see :mod:" "`unicodedata`), either its general category is ``Zs`` (\"Separator, " "space\"), or its bidirectional class is one of ``WS``, ``B``, or ``S``." msgstr "" -#: ../../library/stdtypes.rst:2238 +#: ../../library/stdtypes.rst:2341 msgid "" "Return ``True`` if the string is a titlecased string and there is at least " "one character, for example uppercase characters may only follow uncased " @@ -3576,7 +3725,7 @@ msgid "" "otherwise." msgstr "" -#: ../../library/stdtypes.rst:2244 +#: ../../library/stdtypes.rst:2347 msgid "" ">>> 'Spam, Spam, Spam'.istitle()\n" "True\n" @@ -3592,17 +3741,17 @@ msgstr "" ">>> 'SPAM, SPAM, SPAM'.istitle()\n" "False" -#: ../../library/stdtypes.rst:2253 +#: ../../library/stdtypes.rst:2356 msgid "See also :meth:`title`." msgstr "另請參閱 :meth:`title`。" -#: ../../library/stdtypes.rst:2258 +#: ../../library/stdtypes.rst:2361 msgid "" "Return ``True`` if all cased characters [4]_ in the string are uppercase and " "there is at least one cased character, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:2276 +#: ../../library/stdtypes.rst:2379 msgid "" "Return a string which is the concatenation of the strings in *iterable*. A :" "exc:`TypeError` will be raised if there are any non-string values in " @@ -3610,7 +3759,7 @@ msgid "" "elements is the string providing this method. For example:" msgstr "" -#: ../../library/stdtypes.rst:2281 +#: ../../library/stdtypes.rst:2384 msgid "" ">>> ', '.join(['spam', 'spam', 'spam'])\n" "'spam, spam, spam'\n" @@ -3622,18 +3771,18 @@ msgstr "" ">>> '-'.join('Python')\n" "'P-y-t-h-o-n'" -#: ../../library/stdtypes.rst:2288 +#: ../../library/stdtypes.rst:2391 msgid "See also :meth:`split`." msgstr "另請參閱 :meth:`split`。" -#: ../../library/stdtypes.rst:2293 +#: ../../library/stdtypes.rst:2396 msgid "" "Return the string left justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2299 +#: ../../library/stdtypes.rst:2402 msgid "" ">>> 'Python'.ljust(10)\n" "'Python '\n" @@ -3649,17 +3798,17 @@ msgstr "" ">>> 'Monty Python'.ljust(10, '.')\n" "'Monty Python'" -#: ../../library/stdtypes.rst:2308 +#: ../../library/stdtypes.rst:2411 msgid "See also :meth:`rjust`." msgstr "另請參閱 :meth:`rjust`。" -#: ../../library/stdtypes.rst:2313 +#: ../../library/stdtypes.rst:2416 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "lowercase. For example:" msgstr "" -#: ../../library/stdtypes.rst:2316 +#: ../../library/stdtypes.rst:2419 msgid "" ">>> 'Lower Method Example'.lower()\n" "'lower method example'" @@ -3667,14 +3816,14 @@ msgstr "" ">>> 'Lower Method Example'.lower()\n" "'lower method example'" -#: ../../library/stdtypes.rst:2321 +#: ../../library/stdtypes.rst:2424 msgid "" "The lowercasing algorithm used is `described in section 3.13 'Default Case " "Folding' of the Unicode Standard `__." msgstr "" -#: ../../library/stdtypes.rst:2328 +#: ../../library/stdtypes.rst:2431 msgid "" "Return a copy of the string with leading characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -3683,7 +3832,7 @@ msgid "" "are stripped::" msgstr "" -#: ../../library/stdtypes.rst:2333 +#: ../../library/stdtypes.rst:2436 msgid "" ">>> ' spacious '.lstrip()\n" "'spacious '\n" @@ -3695,13 +3844,13 @@ msgstr "" ">>> 'www.example.com'.lstrip('cmowz.')\n" "'example.com'" -#: ../../library/stdtypes.rst:2338 +#: ../../library/stdtypes.rst:2441 msgid "" "See :meth:`str.removeprefix` for a method that will remove a single prefix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:2341 +#: ../../library/stdtypes.rst:2444 msgid "" ">>> 'Arthur: three!'.lstrip('Arthur: ')\n" "'ee!'\n" @@ -3713,13 +3862,13 @@ msgstr "" ">>> 'Arthur: three!'.removeprefix('Arthur: ')\n" "'three!'" -#: ../../library/stdtypes.rst:2350 +#: ../../library/stdtypes.rst:2453 msgid "" "This static method returns a translation table usable for :meth:`str." "translate`." msgstr "" -#: ../../library/stdtypes.rst:2352 +#: ../../library/stdtypes.rst:2455 msgid "" "If there is only one argument, it must be a dictionary mapping Unicode " "ordinals (integers) or characters (strings of length 1) to Unicode ordinals, " @@ -3727,7 +3876,7 @@ msgid "" "converted to ordinals." msgstr "" -#: ../../library/stdtypes.rst:2357 +#: ../../library/stdtypes.rst:2460 msgid "" "If there are two arguments, they must be strings of equal length, and in the " "resulting dictionary, each character in *from* will be mapped to the " @@ -3735,7 +3884,7 @@ msgid "" "must be a string, whose characters will be mapped to ``None`` in the result." msgstr "" -#: ../../library/stdtypes.rst:2365 +#: ../../library/stdtypes.rst:2468 msgid "" "Split the string at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -3743,13 +3892,13 @@ msgid "" "containing the string itself, followed by two empty strings." msgstr "" -#: ../../library/stdtypes.rst:2373 +#: ../../library/stdtypes.rst:2476 msgid "" "If the string starts with the *prefix* string, return " "``string[len(prefix):]``. Otherwise, return a copy of the original string:" msgstr "" -#: ../../library/stdtypes.rst:2377 +#: ../../library/stdtypes.rst:2480 msgid "" ">>> 'TestHook'.removeprefix('Test')\n" "'Hook'\n" @@ -3761,18 +3910,18 @@ msgstr "" ">>> 'BaseTestCase'.removeprefix('Test')\n" "'BaseTestCase'" -#: ../../library/stdtypes.rst:2386 +#: ../../library/stdtypes.rst:2489 msgid "See also :meth:`removesuffix` and :meth:`startswith`." msgstr "另請參閱 :meth:`removesuffix` 和 :meth:`startswith`。" -#: ../../library/stdtypes.rst:2391 +#: ../../library/stdtypes.rst:2494 msgid "" "If the string ends with the *suffix* string and that *suffix* is not empty, " "return ``string[:-len(suffix)]``. Otherwise, return a copy of the original " "string:" msgstr "" -#: ../../library/stdtypes.rst:2395 +#: ../../library/stdtypes.rst:2498 msgid "" ">>> 'MiscTests'.removesuffix('Tests')\n" "'Misc'\n" @@ -3784,11 +3933,11 @@ msgstr "" ">>> 'TmpDirMixin'.removesuffix('Tests')\n" "'TmpDirMixin'" -#: ../../library/stdtypes.rst:2404 +#: ../../library/stdtypes.rst:2507 msgid "See also :meth:`removeprefix` and :meth:`endswith`." msgstr "另請參閱 :meth:`removeprefix` 和 :meth:`endswith`。" -#: ../../library/stdtypes.rst:2409 +#: ../../library/stdtypes.rst:2512 msgid "" "Return a copy of the string with all occurrences of substring *old* replaced " "by *new*. If *count* is given, only the first *count* occurrences are " @@ -3796,11 +3945,11 @@ msgid "" "replaced." msgstr "" -#: ../../library/stdtypes.rst:2413 +#: ../../library/stdtypes.rst:2516 msgid "*count* is now supported as a keyword argument." msgstr "*count* 現在作為關鍵字引數被支援。" -#: ../../library/stdtypes.rst:2419 +#: ../../library/stdtypes.rst:2522 msgid "" "Return the highest index in the string where substring *sub* is found, such " "that *sub* is contained within ``s[start:end]``. Optional arguments *start* " @@ -3808,7 +3957,7 @@ msgid "" "For example:" msgstr "" -#: ../../library/stdtypes.rst:2424 +#: ../../library/stdtypes.rst:2527 msgid "" ">>> 'spam, spam, spam'.rfind('sp')\n" "12\n" @@ -3820,24 +3969,24 @@ msgstr "" ">>> 'spam, spam, spam'.rfind('sp', 0, 10)\n" "6" -#: ../../library/stdtypes.rst:2431 +#: ../../library/stdtypes.rst:2534 msgid "See also :meth:`find` and :meth:`rindex`." msgstr "另請參閱 :meth:`find` 和 :meth:`rindex`。" -#: ../../library/stdtypes.rst:2436 +#: ../../library/stdtypes.rst:2539 msgid "" "Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is " "not found." msgstr "" -#: ../../library/stdtypes.rst:2442 +#: ../../library/stdtypes.rst:2545 msgid "" "Return the string right justified in a string of length *width*. Padding is " "done using the specified *fillchar* (default is an ASCII space). The " "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2449 +#: ../../library/stdtypes.rst:2552 msgid "" "Split the string at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself, and the part " @@ -3845,7 +3994,7 @@ msgid "" "containing two empty strings, followed by the string itself." msgstr "" -#: ../../library/stdtypes.rst:2457 +#: ../../library/stdtypes.rst:2560 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done, the " @@ -3854,7 +4003,7 @@ msgid "" "behaves like :meth:`split` which is described in detail below." msgstr "" -#: ../../library/stdtypes.rst:2466 +#: ../../library/stdtypes.rst:2569 msgid "" "Return a copy of the string with trailing characters removed. The *chars* " "argument is a string specifying the set of characters to be removed. If " @@ -3863,7 +4012,7 @@ msgid "" "are stripped::" msgstr "" -#: ../../library/stdtypes.rst:2471 +#: ../../library/stdtypes.rst:2574 msgid "" ">>> ' spacious '.rstrip()\n" "' spacious'\n" @@ -3875,13 +4024,13 @@ msgstr "" ">>> 'mississippi'.rstrip('ipz')\n" "'mississ'" -#: ../../library/stdtypes.rst:2476 +#: ../../library/stdtypes.rst:2579 msgid "" "See :meth:`str.removesuffix` for a method that will remove a single suffix " "string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:2479 +#: ../../library/stdtypes.rst:2582 msgid "" ">>> 'Monty Python'.rstrip(' Python')\n" "'M'\n" @@ -3893,7 +4042,7 @@ msgstr "" ">>> 'Monty Python'.removesuffix(' Python')\n" "'Monty'" -#: ../../library/stdtypes.rst:2486 +#: ../../library/stdtypes.rst:2589 msgid "" "Return a list of the words in the string, using *sep* as the delimiter " "string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, " @@ -3902,7 +4051,7 @@ msgid "" "possible splits are made)." msgstr "" -#: ../../library/stdtypes.rst:2492 +#: ../../library/stdtypes.rst:2595 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns " @@ -3912,21 +4061,21 @@ msgid "" "``['']``." msgstr "" -#: ../../library/stdtypes.rst:2499 ../../library/stdtypes.rst:2517 -#: ../../library/stdtypes.rst:2529 ../../library/stdtypes.rst:2583 -#: ../../library/stdtypes.rst:2651 ../../library/stdtypes.rst:2721 -#: ../../library/stdtypes.rst:2816 ../../library/stdtypes.rst:3782 -#: ../../library/stdtypes.rst:3800 ../../library/stdtypes.rst:3890 -#: ../../library/stdtypes.rst:3906 ../../library/stdtypes.rst:3931 -#: ../../library/stdtypes.rst:3945 ../../library/stdtypes.rst:3973 -#: ../../library/stdtypes.rst:3987 ../../library/stdtypes.rst:4005 -#: ../../library/stdtypes.rst:4032 ../../library/stdtypes.rst:4055 -#: ../../library/stdtypes.rst:4082 ../../library/stdtypes.rst:4124 -#: ../../library/stdtypes.rst:4148 +#: ../../library/stdtypes.rst:2602 ../../library/stdtypes.rst:2620 +#: ../../library/stdtypes.rst:2632 ../../library/stdtypes.rst:2686 +#: ../../library/stdtypes.rst:2754 ../../library/stdtypes.rst:2824 +#: ../../library/stdtypes.rst:2919 ../../library/stdtypes.rst:3885 +#: ../../library/stdtypes.rst:3903 ../../library/stdtypes.rst:3993 +#: ../../library/stdtypes.rst:4009 ../../library/stdtypes.rst:4034 +#: ../../library/stdtypes.rst:4048 ../../library/stdtypes.rst:4076 +#: ../../library/stdtypes.rst:4090 ../../library/stdtypes.rst:4108 +#: ../../library/stdtypes.rst:4135 ../../library/stdtypes.rst:4158 +#: ../../library/stdtypes.rst:4185 ../../library/stdtypes.rst:4227 +#: ../../library/stdtypes.rst:4251 msgid "For example::" msgstr "舉例來說: ::" -#: ../../library/stdtypes.rst:2501 +#: ../../library/stdtypes.rst:2604 msgid "" ">>> '1,2,3'.split(',')\n" "['1', '2', '3']\n" @@ -3946,7 +4095,7 @@ msgstr "" ">>> '1<>2<>3<4'.split('<>')\n" "['1', '2', '3<4']" -#: ../../library/stdtypes.rst:2510 +#: ../../library/stdtypes.rst:2613 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive whitespace are regarded as a single separator, " @@ -3956,7 +4105,7 @@ msgid "" "returns ``[]``." msgstr "" -#: ../../library/stdtypes.rst:2519 +#: ../../library/stdtypes.rst:2622 msgid "" ">>> '1 2 3'.split()\n" "['1', '2', '3']\n" @@ -3972,13 +4121,13 @@ msgstr "" ">>> ' 1 2 3 '.split()\n" "['1', '2', '3']" -#: ../../library/stdtypes.rst:2526 +#: ../../library/stdtypes.rst:2629 msgid "" "If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only " "leading runs of consecutive whitespace are considered." msgstr "" -#: ../../library/stdtypes.rst:2531 +#: ../../library/stdtypes.rst:2634 msgid "" ">>> \"\".split(None, 0)\n" "[]\n" @@ -3994,124 +4143,124 @@ msgstr "" ">>> \" foo \".split(maxsplit=0)\n" "['foo ']" -#: ../../library/stdtypes.rst:2538 +#: ../../library/stdtypes.rst:2641 msgid "See also :meth:`join`." msgstr "另請參閱 :meth:`join`。" -#: ../../library/stdtypes.rst:2546 +#: ../../library/stdtypes.rst:2649 msgid "" "Return a list of the lines in the string, breaking at line boundaries. Line " "breaks are not included in the resulting list unless *keepends* is given and " "true." msgstr "" -#: ../../library/stdtypes.rst:2550 +#: ../../library/stdtypes.rst:2653 msgid "" "This method splits on the following line boundaries. In particular, the " "boundaries are a superset of :term:`universal newlines`." msgstr "" -#: ../../library/stdtypes.rst:2554 +#: ../../library/stdtypes.rst:2657 msgid "Representation" msgstr "" -#: ../../library/stdtypes.rst:2554 +#: ../../library/stdtypes.rst:2657 msgid "Description" msgstr "描述" -#: ../../library/stdtypes.rst:2556 +#: ../../library/stdtypes.rst:2659 msgid "``\\n``" msgstr "``\\n``" -#: ../../library/stdtypes.rst:2556 +#: ../../library/stdtypes.rst:2659 msgid "Line Feed" msgstr "" -#: ../../library/stdtypes.rst:2558 +#: ../../library/stdtypes.rst:2661 msgid "``\\r``" msgstr "``\\r``" -#: ../../library/stdtypes.rst:2558 +#: ../../library/stdtypes.rst:2661 msgid "Carriage Return" msgstr "" -#: ../../library/stdtypes.rst:2560 +#: ../../library/stdtypes.rst:2663 msgid "``\\r\\n``" msgstr "``\\r\\n``" -#: ../../library/stdtypes.rst:2560 +#: ../../library/stdtypes.rst:2663 msgid "Carriage Return + Line Feed" msgstr "" -#: ../../library/stdtypes.rst:2562 +#: ../../library/stdtypes.rst:2665 msgid "``\\v`` or ``\\x0b``" msgstr "``\\v`` 或 ``\\x0b``" -#: ../../library/stdtypes.rst:2562 +#: ../../library/stdtypes.rst:2665 msgid "Line Tabulation" msgstr "" -#: ../../library/stdtypes.rst:2564 +#: ../../library/stdtypes.rst:2667 msgid "``\\f`` or ``\\x0c``" msgstr "``\\f`` 或 ``\\x0c``" -#: ../../library/stdtypes.rst:2564 +#: ../../library/stdtypes.rst:2667 msgid "Form Feed" msgstr "" -#: ../../library/stdtypes.rst:2566 +#: ../../library/stdtypes.rst:2669 msgid "``\\x1c``" msgstr "``\\x1c``" -#: ../../library/stdtypes.rst:2566 +#: ../../library/stdtypes.rst:2669 msgid "File Separator" msgstr "" -#: ../../library/stdtypes.rst:2568 +#: ../../library/stdtypes.rst:2671 msgid "``\\x1d``" msgstr "``\\x1d``" -#: ../../library/stdtypes.rst:2568 +#: ../../library/stdtypes.rst:2671 msgid "Group Separator" msgstr "" -#: ../../library/stdtypes.rst:2570 +#: ../../library/stdtypes.rst:2673 msgid "``\\x1e``" msgstr "``\\x1e``" -#: ../../library/stdtypes.rst:2570 +#: ../../library/stdtypes.rst:2673 msgid "Record Separator" msgstr "" -#: ../../library/stdtypes.rst:2572 +#: ../../library/stdtypes.rst:2675 msgid "``\\x85``" msgstr "``\\x85``" -#: ../../library/stdtypes.rst:2572 +#: ../../library/stdtypes.rst:2675 msgid "Next Line (C1 Control Code)" msgstr "" -#: ../../library/stdtypes.rst:2574 +#: ../../library/stdtypes.rst:2677 msgid "``\\u2028``" msgstr "``\\u2028``" -#: ../../library/stdtypes.rst:2574 +#: ../../library/stdtypes.rst:2677 msgid "Line Separator" msgstr "" -#: ../../library/stdtypes.rst:2576 +#: ../../library/stdtypes.rst:2679 msgid "``\\u2029``" msgstr "``\\u2029``" -#: ../../library/stdtypes.rst:2576 +#: ../../library/stdtypes.rst:2679 msgid "Paragraph Separator" msgstr "" -#: ../../library/stdtypes.rst:2581 +#: ../../library/stdtypes.rst:2684 msgid "``\\v`` and ``\\f`` added to list of line boundaries." msgstr "" -#: ../../library/stdtypes.rst:2585 +#: ../../library/stdtypes.rst:2688 msgid "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "['ab c', '', 'de fg', 'kl']\n" @@ -4123,14 +4272,14 @@ msgstr "" ">>> 'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "['ab c\\n', '\\n', 'de fg\\r', 'kl\\r\\n']" -#: ../../library/stdtypes.rst:2590 +#: ../../library/stdtypes.rst:2693 msgid "" "Unlike :meth:`~str.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../library/stdtypes.rst:2594 +#: ../../library/stdtypes.rst:2697 msgid "" ">>> \"\".splitlines()\n" "[]\n" @@ -4142,11 +4291,11 @@ msgstr "" ">>> \"One line\\n\".splitlines()\n" "['One line']" -#: ../../library/stdtypes.rst:2599 +#: ../../library/stdtypes.rst:2702 msgid "For comparison, ``split('\\n')`` gives::" msgstr "" -#: ../../library/stdtypes.rst:2601 +#: ../../library/stdtypes.rst:2704 msgid "" ">>> ''.split('\\n')\n" "['']\n" @@ -4158,7 +4307,7 @@ msgstr "" ">>> 'Two lines\\n'.split('\\n')\n" "['Two lines', '']" -#: ../../library/stdtypes.rst:2609 +#: ../../library/stdtypes.rst:2712 msgid "" "Return ``True`` if string starts with the *prefix*, otherwise return " "``False``. *prefix* can also be a tuple of prefixes to look for. With " @@ -4166,7 +4315,7 @@ msgid "" "*end*, stop comparing string at that position." msgstr "" -#: ../../library/stdtypes.rst:2617 +#: ../../library/stdtypes.rst:2720 msgid "" "Return a copy of the string with the leading and trailing characters " "removed. The *chars* argument is a string specifying the set of characters " @@ -4175,7 +4324,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:2623 +#: ../../library/stdtypes.rst:2726 msgid "" ">>> ' spacious '.strip()\n" "'spacious'\n" @@ -4187,7 +4336,7 @@ msgstr "" ">>> 'www.example.com'.strip('cmowz.')\n" "'example'" -#: ../../library/stdtypes.rst:2628 +#: ../../library/stdtypes.rst:2731 msgid "" "The outermost leading and trailing *chars* argument values are stripped from " "the string. Characters are removed from the leading end until reaching a " @@ -4195,7 +4344,7 @@ msgid "" "A similar action takes place on the trailing end. For example::" msgstr "" -#: ../../library/stdtypes.rst:2634 +#: ../../library/stdtypes.rst:2737 msgid "" ">>> comment_string = '#....... Section 3.2.1 Issue #32 .......'\n" ">>> comment_string.strip('.#! ')\n" @@ -4205,20 +4354,20 @@ msgstr "" ">>> comment_string.strip('.#! ')\n" "'Section 3.2.1 Issue #32'" -#: ../../library/stdtypes.rst:2641 +#: ../../library/stdtypes.rst:2744 msgid "" "Return a copy of the string with uppercase characters converted to lowercase " "and vice versa. Note that it is not necessarily true that ``s.swapcase()." "swapcase() == s``." msgstr "" -#: ../../library/stdtypes.rst:2648 +#: ../../library/stdtypes.rst:2751 msgid "" "Return a titlecased version of the string where words start with an " "uppercase character and the remaining characters are lowercase." msgstr "" -#: ../../library/stdtypes.rst:2653 +#: ../../library/stdtypes.rst:2756 msgid "" ">>> 'Hello world'.title()\n" "'Hello World'" @@ -4226,7 +4375,7 @@ msgstr "" ">>> 'Hello world'.title()\n" "'Hello World'" -#: ../../library/stdtypes.rst:2656 ../../library/stdtypes.rst:4092 +#: ../../library/stdtypes.rst:2759 ../../library/stdtypes.rst:4195 msgid "" "The algorithm uses a simple language-independent definition of a word as " "groups of consecutive letters. The definition works in many contexts but it " @@ -4234,7 +4383,7 @@ msgid "" "which may not be the desired result::" msgstr "" -#: ../../library/stdtypes.rst:2661 +#: ../../library/stdtypes.rst:2764 msgid "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" @@ -4242,19 +4391,19 @@ msgstr "" ">>> \"they're bill's friends from the UK\".title()\n" "\"They'Re Bill'S Friends From The Uk\"" -#: ../../library/stdtypes.rst:2664 +#: ../../library/stdtypes.rst:2767 msgid "" "The :func:`string.capwords` function does not have this problem, as it " "splits words on spaces only." msgstr "" -#: ../../library/stdtypes.rst:2667 +#: ../../library/stdtypes.rst:2770 msgid "" "Alternatively, a workaround for apostrophes can be constructed using regular " "expressions::" msgstr "" -#: ../../library/stdtypes.rst:2670 +#: ../../library/stdtypes.rst:2773 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -4274,11 +4423,11 @@ msgstr "" ">>> titlecase(\"they're bill's friends.\")\n" "\"They're Bill's Friends.\"" -#: ../../library/stdtypes.rst:2679 +#: ../../library/stdtypes.rst:2782 msgid "See also :meth:`istitle`." msgstr "另請參閱 :meth:`istitle`。" -#: ../../library/stdtypes.rst:2684 +#: ../../library/stdtypes.rst:2787 msgid "" "Return a copy of the string in which each character has been mapped through " "the given translation table. The table must be an object that implements " @@ -4290,19 +4439,19 @@ msgid "" "exception, to map the character to itself." msgstr "" -#: ../../library/stdtypes.rst:2693 +#: ../../library/stdtypes.rst:2796 msgid "" "You can use :meth:`str.maketrans` to create a translation map from character-" "to-character mappings in different formats." msgstr "" -#: ../../library/stdtypes.rst:2696 +#: ../../library/stdtypes.rst:2799 msgid "" "See also the :mod:`codecs` module for a more flexible approach to custom " "character mappings." msgstr "" -#: ../../library/stdtypes.rst:2702 +#: ../../library/stdtypes.rst:2805 msgid "" "Return a copy of the string with all the cased characters [4]_ converted to " "uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s`` " @@ -4311,14 +4460,14 @@ msgid "" "titlecase)." msgstr "" -#: ../../library/stdtypes.rst:2708 +#: ../../library/stdtypes.rst:2811 msgid "" "The uppercasing algorithm used is `described in section 3.13 'Default Case " "Folding' of the Unicode Standard `__." msgstr "" -#: ../../library/stdtypes.rst:2715 +#: ../../library/stdtypes.rst:2818 msgid "" "Return a copy of the string left filled with ASCII ``'0'`` digits to make a " "string of length *width*. A leading sign prefix (``'+'``/``'-'``) is handled " @@ -4326,7 +4475,7 @@ msgid "" "original string is returned if *width* is less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:2723 +#: ../../library/stdtypes.rst:2826 msgid "" ">>> \"42\".zfill(5)\n" "'00042'\n" @@ -4338,27 +4487,27 @@ msgstr "" ">>> \"-42\".zfill(5)\n" "'-0042'" -#: ../../library/stdtypes.rst:2746 +#: ../../library/stdtypes.rst:2849 msgid "Formatted String Literals (f-strings)" msgstr "" -#: ../../library/stdtypes.rst:2749 +#: ../../library/stdtypes.rst:2852 msgid "" "The :keyword:`await` and :keyword:`async for` can be used in expressions " "within f-strings." msgstr "" -#: ../../library/stdtypes.rst:2752 +#: ../../library/stdtypes.rst:2855 msgid "Added the debug specifier (``=``)" msgstr "" -#: ../../library/stdtypes.rst:2754 +#: ../../library/stdtypes.rst:2857 msgid "" "Many restrictions on expressions within f-strings have been removed. " "Notably, nested strings, comments, and backslashes are now permitted." msgstr "" -#: ../../library/stdtypes.rst:2758 +#: ../../library/stdtypes.rst:2861 msgid "" "An :dfn:`f-string` (formally a :dfn:`formatted string literal`) is a string " "literal that is prefixed with ``f`` or ``F``. This type of string literal " @@ -4367,29 +4516,29 @@ msgid "" "replacement field must contain an expression, optionally followed by:" msgstr "" -#: ../../library/stdtypes.rst:2765 +#: ../../library/stdtypes.rst:2868 msgid "a *debug specifier* -- an equal sign (``=``);" msgstr "" -#: ../../library/stdtypes.rst:2766 +#: ../../library/stdtypes.rst:2869 msgid "a *conversion specifier* -- ``!s``, ``!r`` or ``!a``; and/or" msgstr "" -#: ../../library/stdtypes.rst:2767 +#: ../../library/stdtypes.rst:2870 msgid "a *format specifier* prefixed with a colon (``:``)." msgstr "" -#: ../../library/stdtypes.rst:2769 +#: ../../library/stdtypes.rst:2872 msgid "" "See the :ref:`Lexical Analysis section on f-strings ` for details " "on the syntax of these fields." msgstr "" -#: ../../library/stdtypes.rst:2773 +#: ../../library/stdtypes.rst:2876 msgid "Debug specifier" msgstr "" -#: ../../library/stdtypes.rst:2777 +#: ../../library/stdtypes.rst:2880 msgid "" "If a debug specifier -- an equal sign (``=``) -- appears after the " "replacement field expression, the resulting f-string will contain the " @@ -4397,7 +4546,7 @@ msgid "" "is often useful for debugging::" msgstr "" -#: ../../library/stdtypes.rst:2782 +#: ../../library/stdtypes.rst:2885 msgid "" ">>> number = 14.3\n" ">>> f'{number=}'\n" @@ -4407,13 +4556,13 @@ msgstr "" ">>> f'{number=}'\n" "'number=14.3'" -#: ../../library/stdtypes.rst:2786 +#: ../../library/stdtypes.rst:2889 msgid "" "Whitespace before, inside and after the expression, as well as whitespace " "after the equal sign, is significant --- it is retained in the result::" msgstr "" -#: ../../library/stdtypes.rst:2789 +#: ../../library/stdtypes.rst:2892 msgid "" ">>> f'{ number - 4 = }'\n" "' number - 4 = 10.3'" @@ -4421,17 +4570,17 @@ msgstr "" ">>> f'{ number - 4 = }'\n" "' number - 4 = 10.3'" -#: ../../library/stdtypes.rst:2794 +#: ../../library/stdtypes.rst:2897 msgid "Conversion specifier" msgstr "" -#: ../../library/stdtypes.rst:2796 +#: ../../library/stdtypes.rst:2899 msgid "" "By default, the value of a replacement field expression is converted to a " "string using :func:`str`::" msgstr "" -#: ../../library/stdtypes.rst:2799 +#: ../../library/stdtypes.rst:2902 msgid "" ">>> from fractions import Fraction\n" ">>> one_third = Fraction(1, 3)\n" @@ -4443,13 +4592,13 @@ msgstr "" ">>> f'{one_third}'\n" "'1/3'" -#: ../../library/stdtypes.rst:2804 +#: ../../library/stdtypes.rst:2907 msgid "" "When a debug specifier but no format specifier is used, the default " "conversion instead uses :func:`repr`::" msgstr "" -#: ../../library/stdtypes.rst:2807 +#: ../../library/stdtypes.rst:2910 msgid "" ">>> f'{one_third = }'\n" "'one_third = Fraction(1, 3)'" @@ -4457,24 +4606,24 @@ msgstr "" ">>> f'{one_third = }'\n" "'one_third = Fraction(1, 3)'" -#: ../../library/stdtypes.rst:2810 +#: ../../library/stdtypes.rst:2913 msgid "" "The conversion can be specified explicitly using one of these specifiers:" msgstr "" -#: ../../library/stdtypes.rst:2812 +#: ../../library/stdtypes.rst:2915 msgid "``!s`` for :func:`str`" msgstr "``!s`` 用於 :func:`str`" -#: ../../library/stdtypes.rst:2813 +#: ../../library/stdtypes.rst:2916 msgid "``!r`` for :func:`repr`" msgstr "``!r`` 用於 :func:`repr`" -#: ../../library/stdtypes.rst:2814 +#: ../../library/stdtypes.rst:2917 msgid "``!a`` for :func:`ascii`" msgstr "``!a`` 用於 :func:`ascii`" -#: ../../library/stdtypes.rst:2818 +#: ../../library/stdtypes.rst:2921 msgid "" ">>> str(one_third)\n" "'1/3'\n" @@ -4506,11 +4655,11 @@ msgstr "" ">>> f'{string = !a}'\n" "\"string = '\\\\xa1ko\\\\u010dka \\\\U0001f638!'\"" -#: ../../library/stdtypes.rst:2835 +#: ../../library/stdtypes.rst:2938 msgid "Format specifier" msgstr "" -#: ../../library/stdtypes.rst:2837 +#: ../../library/stdtypes.rst:2940 msgid "" "After the expression has been evaluated, and possibly converted using an " "explicit conversion specifier, it is formatted using the :func:`format` " @@ -4520,7 +4669,7 @@ msgid "" "the replacement field. For example::" msgstr "" -#: ../../library/stdtypes.rst:2844 +#: ../../library/stdtypes.rst:2947 msgid "" ">>> from fractions import Fraction\n" ">>> one_third = Fraction(1, 3)\n" @@ -4544,29 +4693,29 @@ msgstr "" ">>> f'{one_third = :~>10}~'\n" "'one_third = ~~~~~~~1/3~'" -#: ../../library/stdtypes.rst:2858 +#: ../../library/stdtypes.rst:2961 msgid "Template String Literals (t-strings)" msgstr "模板字串字面值 (t-strings)" -#: ../../library/stdtypes.rst:2860 +#: ../../library/stdtypes.rst:2963 msgid "" "An :dfn:`t-string` (formally a :dfn:`template string literal`) is a string " "literal that is prefixed with ``t`` or ``T``." msgstr "" -#: ../../library/stdtypes.rst:2863 +#: ../../library/stdtypes.rst:2966 msgid "" "These strings follow the same syntax and evaluation rules as :ref:`formatted " "string literals `, with for the following differences:" msgstr "" -#: ../../library/stdtypes.rst:2867 +#: ../../library/stdtypes.rst:2970 msgid "" "Rather than evaluating to a ``str`` object, template string literals " "evaluate to a :class:`string.templatelib.Template` object." msgstr "" -#: ../../library/stdtypes.rst:2870 +#: ../../library/stdtypes.rst:2973 msgid "" "The :func:`format` protocol is not used. Instead, the format specifier and " "conversions (if any) are passed to a new :class:`~string.templatelib." @@ -4575,7 +4724,7 @@ msgid "" "Template` object to decide how to handle format specifiers and conversions." msgstr "" -#: ../../library/stdtypes.rst:2877 +#: ../../library/stdtypes.rst:2980 msgid "" "Format specifiers containing nested replacement fields are evaluated " "eagerly, prior to being passed to the :class:`~string.templatelib." @@ -4585,7 +4734,7 @@ msgid "" "to be ``2``, the resulting format specifier would be ``'.2f'``." msgstr "" -#: ../../library/stdtypes.rst:2885 +#: ../../library/stdtypes.rst:2988 msgid "" "When the equals sign ``'='`` is provided in an interpolation expression, the " "text of the expression is appended to the literal string that precedes the " @@ -4597,18 +4746,18 @@ msgid "" "behaviour." msgstr "" -#: ../../library/stdtypes.rst:2899 +#: ../../library/stdtypes.rst:3002 msgid "``printf``-style String Formatting" msgstr "" -#: ../../library/stdtypes.rst:2912 +#: ../../library/stdtypes.rst:3015 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " "dictionaries correctly)." msgstr "" -#: ../../library/stdtypes.rst:2916 +#: ../../library/stdtypes.rst:3019 msgid "" "Using :ref:`formatted string literals `, the :meth:`str.format` " "interface, or :class:`string.Template` may help avoid these errors. Each of " @@ -4616,7 +4765,7 @@ msgid "" "flexibility, and/or extensibility." msgstr "" -#: ../../library/stdtypes.rst:2921 +#: ../../library/stdtypes.rst:3024 msgid "" "String objects have one unique built-in operation: the ``%`` operator " "(modulo). This is also known as the string *formatting* or *interpolation* " @@ -4626,7 +4775,7 @@ msgid "" "function in the C language. For example:" msgstr "" -#: ../../library/stdtypes.rst:2928 +#: ../../library/stdtypes.rst:3031 msgid "" ">>> print('%s has %d quote types.' % ('Python', 2))\n" "Python has 2 quote types." @@ -4634,7 +4783,7 @@ msgstr "" ">>> print('%s has %d quote types.' % ('Python', 2))\n" "Python has 2 quote types." -#: ../../library/stdtypes.rst:2933 +#: ../../library/stdtypes.rst:3036 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -4642,36 +4791,36 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:2943 ../../library/stdtypes.rst:4203 +#: ../../library/stdtypes.rst:3046 ../../library/stdtypes.rst:4306 msgid "" "A conversion specifier contains two or more characters and has the following " "components, which must occur in this order:" msgstr "" -#: ../../library/stdtypes.rst:2946 ../../library/stdtypes.rst:4206 +#: ../../library/stdtypes.rst:3049 ../../library/stdtypes.rst:4309 msgid "The ``'%'`` character, which marks the start of the specifier." msgstr "" -#: ../../library/stdtypes.rst:2948 ../../library/stdtypes.rst:4208 +#: ../../library/stdtypes.rst:3051 ../../library/stdtypes.rst:4311 msgid "" "Mapping key (optional), consisting of a parenthesised sequence of characters " "(for example, ``(somename)``)." msgstr "" -#: ../../library/stdtypes.rst:2951 ../../library/stdtypes.rst:4211 +#: ../../library/stdtypes.rst:3054 ../../library/stdtypes.rst:4314 msgid "" "Conversion flags (optional), which affect the result of some conversion " "types." msgstr "" -#: ../../library/stdtypes.rst:2954 ../../library/stdtypes.rst:4214 +#: ../../library/stdtypes.rst:3057 ../../library/stdtypes.rst:4317 msgid "" "Minimum field width (optional). If specified as an ``'*'`` (asterisk), the " "actual width is read from the next element of the tuple in *values*, and the " "object to convert comes after the minimum field width and optional precision." msgstr "" -#: ../../library/stdtypes.rst:2958 ../../library/stdtypes.rst:4218 +#: ../../library/stdtypes.rst:3061 ../../library/stdtypes.rst:4321 msgid "" "Precision (optional), given as a ``'.'`` (dot) followed by the precision. " "If specified as ``'*'`` (an asterisk), the actual precision is read from the " @@ -4679,15 +4828,15 @@ msgid "" "the precision." msgstr "" -#: ../../library/stdtypes.rst:2963 ../../library/stdtypes.rst:4223 +#: ../../library/stdtypes.rst:3066 ../../library/stdtypes.rst:4326 msgid "Length modifier (optional)." msgstr "" -#: ../../library/stdtypes.rst:2965 ../../library/stdtypes.rst:4225 +#: ../../library/stdtypes.rst:3068 ../../library/stdtypes.rst:4328 msgid "Conversion type." msgstr "" -#: ../../library/stdtypes.rst:2967 +#: ../../library/stdtypes.rst:3070 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the string *must* include a parenthesised mapping key into that " @@ -4695,279 +4844,279 @@ msgid "" "selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:2976 ../../library/stdtypes.rst:4236 +#: ../../library/stdtypes.rst:3079 ../../library/stdtypes.rst:4339 msgid "" "In this case no ``*`` specifiers may occur in a format (since they require a " "sequential parameter list)." msgstr "" -#: ../../library/stdtypes.rst:2979 ../../library/stdtypes.rst:4239 +#: ../../library/stdtypes.rst:3082 ../../library/stdtypes.rst:4342 msgid "The conversion flag characters are:" msgstr "" -#: ../../library/stdtypes.rst:2988 ../../library/stdtypes.rst:4248 +#: ../../library/stdtypes.rst:3091 ../../library/stdtypes.rst:4351 msgid "Flag" msgstr "" -#: ../../library/stdtypes.rst:2990 ../../library/stdtypes.rst:4250 +#: ../../library/stdtypes.rst:3093 ../../library/stdtypes.rst:4353 msgid "``'#'``" msgstr "``'#'``" -#: ../../library/stdtypes.rst:2990 ../../library/stdtypes.rst:4250 +#: ../../library/stdtypes.rst:3093 ../../library/stdtypes.rst:4353 msgid "" "The value conversion will use the \"alternate form\" (where defined below)." msgstr "" -#: ../../library/stdtypes.rst:2993 ../../library/stdtypes.rst:4253 +#: ../../library/stdtypes.rst:3096 ../../library/stdtypes.rst:4356 msgid "``'0'``" msgstr "``'0'``" -#: ../../library/stdtypes.rst:2993 ../../library/stdtypes.rst:4253 +#: ../../library/stdtypes.rst:3096 ../../library/stdtypes.rst:4356 msgid "The conversion will be zero padded for numeric values." msgstr "" -#: ../../library/stdtypes.rst:2995 ../../library/stdtypes.rst:4255 +#: ../../library/stdtypes.rst:3098 ../../library/stdtypes.rst:4358 msgid "``'-'``" msgstr "``'-'``" -#: ../../library/stdtypes.rst:2995 ../../library/stdtypes.rst:4255 +#: ../../library/stdtypes.rst:3098 ../../library/stdtypes.rst:4358 msgid "" "The converted value is left adjusted (overrides the ``'0'`` conversion if " "both are given)." msgstr "" -#: ../../library/stdtypes.rst:2998 ../../library/stdtypes.rst:4258 +#: ../../library/stdtypes.rst:3101 ../../library/stdtypes.rst:4361 msgid "``' '``" msgstr "``' '``" -#: ../../library/stdtypes.rst:2998 ../../library/stdtypes.rst:4258 +#: ../../library/stdtypes.rst:3101 ../../library/stdtypes.rst:4361 msgid "" "(a space) A blank should be left before a positive number (or empty string) " "produced by a signed conversion." msgstr "" -#: ../../library/stdtypes.rst:3001 ../../library/stdtypes.rst:4261 +#: ../../library/stdtypes.rst:3104 ../../library/stdtypes.rst:4364 msgid "``'+'``" msgstr "``'+'``" -#: ../../library/stdtypes.rst:3001 ../../library/stdtypes.rst:4261 +#: ../../library/stdtypes.rst:3104 ../../library/stdtypes.rst:4364 msgid "" "A sign character (``'+'`` or ``'-'``) will precede the conversion (overrides " "a \"space\" flag)." msgstr "" -#: ../../library/stdtypes.rst:3005 ../../library/stdtypes.rst:4265 +#: ../../library/stdtypes.rst:3108 ../../library/stdtypes.rst:4368 msgid "" "A length modifier (``h``, ``l``, or ``L``) may be present, but is ignored as " "it is not necessary for Python -- so e.g. ``%ld`` is identical to ``%d``." msgstr "" -#: ../../library/stdtypes.rst:3008 ../../library/stdtypes.rst:4268 +#: ../../library/stdtypes.rst:3111 ../../library/stdtypes.rst:4371 msgid "The conversion types are:" msgstr "" -#: ../../library/stdtypes.rst:3011 ../../library/stdtypes.rst:4271 +#: ../../library/stdtypes.rst:3114 ../../library/stdtypes.rst:4374 msgid "Conversion" msgstr "" -#: ../../library/stdtypes.rst:3013 ../../library/stdtypes.rst:4273 +#: ../../library/stdtypes.rst:3116 ../../library/stdtypes.rst:4376 msgid "``'d'``" msgstr "``'d'``" -#: ../../library/stdtypes.rst:3013 ../../library/stdtypes.rst:3015 -#: ../../library/stdtypes.rst:4273 ../../library/stdtypes.rst:4275 +#: ../../library/stdtypes.rst:3116 ../../library/stdtypes.rst:3118 +#: ../../library/stdtypes.rst:4376 ../../library/stdtypes.rst:4378 msgid "Signed integer decimal." msgstr "" -#: ../../library/stdtypes.rst:3015 ../../library/stdtypes.rst:4275 +#: ../../library/stdtypes.rst:3118 ../../library/stdtypes.rst:4378 msgid "``'i'``" msgstr "``'i'``" -#: ../../library/stdtypes.rst:3017 ../../library/stdtypes.rst:4277 +#: ../../library/stdtypes.rst:3120 ../../library/stdtypes.rst:4380 msgid "``'o'``" msgstr "``'o'``" -#: ../../library/stdtypes.rst:3017 ../../library/stdtypes.rst:4277 +#: ../../library/stdtypes.rst:3120 ../../library/stdtypes.rst:4380 msgid "Signed octal value." msgstr "" -#: ../../library/stdtypes.rst:3019 ../../library/stdtypes.rst:4279 +#: ../../library/stdtypes.rst:3122 ../../library/stdtypes.rst:4382 msgid "``'u'``" msgstr "``'u'``" -#: ../../library/stdtypes.rst:3019 ../../library/stdtypes.rst:4279 +#: ../../library/stdtypes.rst:3122 ../../library/stdtypes.rst:4382 msgid "Obsolete type -- it is identical to ``'d'``." msgstr "" -#: ../../library/stdtypes.rst:3021 ../../library/stdtypes.rst:4281 +#: ../../library/stdtypes.rst:3124 ../../library/stdtypes.rst:4384 msgid "``'x'``" msgstr "``'x'``" -#: ../../library/stdtypes.rst:3021 ../../library/stdtypes.rst:4281 +#: ../../library/stdtypes.rst:3124 ../../library/stdtypes.rst:4384 msgid "Signed hexadecimal (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:3023 ../../library/stdtypes.rst:4283 +#: ../../library/stdtypes.rst:3126 ../../library/stdtypes.rst:4386 msgid "``'X'``" msgstr "``'X'``" -#: ../../library/stdtypes.rst:3023 ../../library/stdtypes.rst:4283 +#: ../../library/stdtypes.rst:3126 ../../library/stdtypes.rst:4386 msgid "Signed hexadecimal (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:3025 ../../library/stdtypes.rst:4285 +#: ../../library/stdtypes.rst:3128 ../../library/stdtypes.rst:4388 msgid "``'e'``" msgstr "``'e'``" -#: ../../library/stdtypes.rst:3025 ../../library/stdtypes.rst:4285 +#: ../../library/stdtypes.rst:3128 ../../library/stdtypes.rst:4388 msgid "Floating-point exponential format (lowercase)." msgstr "" -#: ../../library/stdtypes.rst:3027 ../../library/stdtypes.rst:4287 +#: ../../library/stdtypes.rst:3130 ../../library/stdtypes.rst:4390 msgid "``'E'``" msgstr "``'E'``" -#: ../../library/stdtypes.rst:3027 ../../library/stdtypes.rst:4287 +#: ../../library/stdtypes.rst:3130 ../../library/stdtypes.rst:4390 msgid "Floating-point exponential format (uppercase)." msgstr "" -#: ../../library/stdtypes.rst:3029 ../../library/stdtypes.rst:4289 +#: ../../library/stdtypes.rst:3132 ../../library/stdtypes.rst:4392 msgid "``'f'``" msgstr "``'f'``" -#: ../../library/stdtypes.rst:3029 ../../library/stdtypes.rst:3031 -#: ../../library/stdtypes.rst:4289 ../../library/stdtypes.rst:4291 +#: ../../library/stdtypes.rst:3132 ../../library/stdtypes.rst:3134 +#: ../../library/stdtypes.rst:4392 ../../library/stdtypes.rst:4394 msgid "Floating-point decimal format." msgstr "" -#: ../../library/stdtypes.rst:3031 ../../library/stdtypes.rst:4291 +#: ../../library/stdtypes.rst:3134 ../../library/stdtypes.rst:4394 msgid "``'F'``" msgstr "``'F'``" -#: ../../library/stdtypes.rst:3033 ../../library/stdtypes.rst:4293 +#: ../../library/stdtypes.rst:3136 ../../library/stdtypes.rst:4396 msgid "``'g'``" msgstr "``'g'``" -#: ../../library/stdtypes.rst:3033 ../../library/stdtypes.rst:4293 +#: ../../library/stdtypes.rst:3136 ../../library/stdtypes.rst:4396 msgid "" "Floating-point format. Uses lowercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:4297 +#: ../../library/stdtypes.rst:3140 ../../library/stdtypes.rst:4400 msgid "``'G'``" msgstr "``'G'``" -#: ../../library/stdtypes.rst:3037 ../../library/stdtypes.rst:4297 +#: ../../library/stdtypes.rst:3140 ../../library/stdtypes.rst:4400 msgid "" "Floating-point format. Uses uppercase exponential format if exponent is less " "than -4 or not less than precision, decimal format otherwise." msgstr "" -#: ../../library/stdtypes.rst:3041 ../../library/stdtypes.rst:4301 +#: ../../library/stdtypes.rst:3144 ../../library/stdtypes.rst:4404 msgid "``'c'``" msgstr "``'c'``" -#: ../../library/stdtypes.rst:3041 +#: ../../library/stdtypes.rst:3144 msgid "Single character (accepts integer or single character string)." msgstr "" -#: ../../library/stdtypes.rst:3044 ../../library/stdtypes.rst:4314 +#: ../../library/stdtypes.rst:3147 ../../library/stdtypes.rst:4417 msgid "``'r'``" msgstr "``'r'``" -#: ../../library/stdtypes.rst:3044 +#: ../../library/stdtypes.rst:3147 msgid "String (converts any Python object using :func:`repr`)." msgstr "" -#: ../../library/stdtypes.rst:3047 ../../library/stdtypes.rst:4308 +#: ../../library/stdtypes.rst:3150 ../../library/stdtypes.rst:4411 msgid "``'s'``" msgstr "``'s'``" -#: ../../library/stdtypes.rst:3047 +#: ../../library/stdtypes.rst:3150 msgid "String (converts any Python object using :func:`str`)." msgstr "" -#: ../../library/stdtypes.rst:3050 ../../library/stdtypes.rst:4311 +#: ../../library/stdtypes.rst:3153 ../../library/stdtypes.rst:4414 msgid "``'a'``" msgstr "``'a'``" -#: ../../library/stdtypes.rst:3050 +#: ../../library/stdtypes.rst:3153 msgid "String (converts any Python object using :func:`ascii`)." msgstr "" -#: ../../library/stdtypes.rst:3053 ../../library/stdtypes.rst:4317 +#: ../../library/stdtypes.rst:3156 ../../library/stdtypes.rst:4420 msgid "``'%'``" msgstr "``'%'``" -#: ../../library/stdtypes.rst:3053 ../../library/stdtypes.rst:4317 +#: ../../library/stdtypes.rst:3156 ../../library/stdtypes.rst:4420 msgid "No argument is converted, results in a ``'%'`` character in the result." msgstr "" -#: ../../library/stdtypes.rst:3060 ../../library/stdtypes.rst:4324 +#: ../../library/stdtypes.rst:3163 ../../library/stdtypes.rst:4427 msgid "" "The alternate form causes a leading octal specifier (``'0o'``) to be " "inserted before the first digit." msgstr "" -#: ../../library/stdtypes.rst:3064 ../../library/stdtypes.rst:4328 +#: ../../library/stdtypes.rst:3167 ../../library/stdtypes.rst:4431 msgid "" "The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on " "whether the ``'x'`` or ``'X'`` format was used) to be inserted before the " "first digit." msgstr "" -#: ../../library/stdtypes.rst:3068 ../../library/stdtypes.rst:4332 +#: ../../library/stdtypes.rst:3171 ../../library/stdtypes.rst:4435 msgid "" "The alternate form causes the result to always contain a decimal point, even " "if no digits follow it." msgstr "" -#: ../../library/stdtypes.rst:3071 ../../library/stdtypes.rst:4335 +#: ../../library/stdtypes.rst:3174 ../../library/stdtypes.rst:4438 msgid "" "The precision determines the number of digits after the decimal point and " "defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:3075 ../../library/stdtypes.rst:4339 +#: ../../library/stdtypes.rst:3178 ../../library/stdtypes.rst:4442 msgid "" "The alternate form causes the result to always contain a decimal point, and " "trailing zeroes are not removed as they would otherwise be." msgstr "" -#: ../../library/stdtypes.rst:3078 ../../library/stdtypes.rst:4342 +#: ../../library/stdtypes.rst:3181 ../../library/stdtypes.rst:4445 msgid "" "The precision determines the number of significant digits before and after " "the decimal point and defaults to 6." msgstr "" -#: ../../library/stdtypes.rst:3082 ../../library/stdtypes.rst:4346 +#: ../../library/stdtypes.rst:3185 ../../library/stdtypes.rst:4449 msgid "If precision is ``N``, the output is truncated to ``N`` characters." msgstr "" -#: ../../library/stdtypes.rst:3085 ../../library/stdtypes.rst:4355 +#: ../../library/stdtypes.rst:3188 ../../library/stdtypes.rst:4458 msgid "See :pep:`237`." msgstr "參閱 :pep:`237`。" -#: ../../library/stdtypes.rst:3087 +#: ../../library/stdtypes.rst:3190 msgid "" "Since Python strings have an explicit length, ``%s`` conversions do not " "assume that ``'\\0'`` is the end of the string." msgstr "" -#: ../../library/stdtypes.rst:3092 +#: ../../library/stdtypes.rst:3195 msgid "" "``%f`` conversions for numbers whose absolute value is over 1e50 are no " "longer replaced by ``%g`` conversions." msgstr "" -#: ../../library/stdtypes.rst:3103 +#: ../../library/stdtypes.rst:3206 msgid "" "Binary Sequence Types --- :class:`bytes`, :class:`bytearray`, :class:" "`memoryview`" msgstr "" -#: ../../library/stdtypes.rst:3111 +#: ../../library/stdtypes.rst:3214 msgid "" "The core built-in types for manipulating binary data are :class:`bytes` and :" "class:`bytearray`. They are supported by :class:`memoryview` which uses the :" @@ -4975,17 +5124,17 @@ msgid "" "objects without needing to make a copy." msgstr "" -#: ../../library/stdtypes.rst:3116 +#: ../../library/stdtypes.rst:3219 msgid "" "The :mod:`array` module supports efficient storage of basic data types like " "32-bit integers and IEEE754 double-precision floating values." msgstr "" -#: ../../library/stdtypes.rst:3122 +#: ../../library/stdtypes.rst:3225 msgid "Bytes Objects" msgstr "" -#: ../../library/stdtypes.rst:3126 +#: ../../library/stdtypes.rst:3229 msgid "" "Bytes objects are immutable sequences of single bytes. Since many major " "binary protocols are based on the ASCII text encoding, bytes objects offer " @@ -4993,40 +5142,40 @@ msgid "" "and are closely related to string objects in a variety of other ways." msgstr "" -#: ../../library/stdtypes.rst:3134 +#: ../../library/stdtypes.rst:3237 msgid "" "Firstly, the syntax for bytes literals is largely the same as that for " "string literals, except that a ``b`` prefix is added:" msgstr "" -#: ../../library/stdtypes.rst:3137 +#: ../../library/stdtypes.rst:3240 msgid "Single quotes: ``b'still allows embedded \"double\" quotes'``" msgstr "" -#: ../../library/stdtypes.rst:3138 +#: ../../library/stdtypes.rst:3241 msgid "Double quotes: ``b\"still allows embedded 'single' quotes\"``" msgstr "" -#: ../../library/stdtypes.rst:3139 +#: ../../library/stdtypes.rst:3242 msgid "" "Triple quoted: ``b'''3 single quotes'''``, ``b\"\"\"3 double quotes\"\"\"``" msgstr "" -#: ../../library/stdtypes.rst:3141 +#: ../../library/stdtypes.rst:3244 msgid "" "Only ASCII characters are permitted in bytes literals (regardless of the " "declared source code encoding). Any binary values over 127 must be entered " "into bytes literals using the appropriate escape sequence." msgstr "" -#: ../../library/stdtypes.rst:3145 +#: ../../library/stdtypes.rst:3248 msgid "" "As with string literals, bytes literals may also use a ``r`` prefix to " "disable processing of escape sequences. See :ref:`strings` for more about " "the various forms of bytes literal, including supported escape sequences." msgstr "" -#: ../../library/stdtypes.rst:3149 +#: ../../library/stdtypes.rst:3252 msgid "" "While bytes literals and representations are based on ASCII text, bytes " "objects actually behave like immutable sequences of integers, with each " @@ -5039,29 +5188,29 @@ msgid "" "compatible will usually lead to data corruption)." msgstr "" -#: ../../library/stdtypes.rst:3159 +#: ../../library/stdtypes.rst:3262 msgid "" "In addition to the literal forms, bytes objects can be created in a number " "of other ways:" msgstr "" -#: ../../library/stdtypes.rst:3162 +#: ../../library/stdtypes.rst:3265 msgid "A zero-filled bytes object of a specified length: ``bytes(10)``" msgstr "" -#: ../../library/stdtypes.rst:3163 +#: ../../library/stdtypes.rst:3266 msgid "From an iterable of integers: ``bytes(range(20))``" msgstr "" -#: ../../library/stdtypes.rst:3164 +#: ../../library/stdtypes.rst:3267 msgid "Copying existing binary data via the buffer protocol: ``bytes(obj)``" msgstr "" -#: ../../library/stdtypes.rst:3166 +#: ../../library/stdtypes.rst:3269 msgid "Also see the :ref:`bytes ` built-in." msgstr "另見內建的 :ref:`bytes `。" -#: ../../library/stdtypes.rst:3168 +#: ../../library/stdtypes.rst:3271 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -5069,38 +5218,38 @@ msgid "" "that format:" msgstr "" -#: ../../library/stdtypes.rst:3174 +#: ../../library/stdtypes.rst:3277 msgid "" "This :class:`bytes` class method returns a bytes object, decoding the given " "string object. The string must contain two hexadecimal digits per byte, " "with ASCII whitespace being ignored." msgstr "" -#: ../../library/stdtypes.rst:3181 +#: ../../library/stdtypes.rst:3284 msgid "" ":meth:`bytes.fromhex` now skips all ASCII whitespace in the string, not just " "spaces." msgstr "" -#: ../../library/stdtypes.rst:3185 +#: ../../library/stdtypes.rst:3288 msgid "" ":meth:`bytes.fromhex` now accepts ASCII :class:`bytes` and :term:`bytes-like " "objects ` as input." msgstr "" -#: ../../library/stdtypes.rst:3189 +#: ../../library/stdtypes.rst:3292 msgid "" "A reverse conversion function exists to transform a bytes object into its " "hexadecimal representation." msgstr "" -#: ../../library/stdtypes.rst:3195 ../../library/stdtypes.rst:3286 +#: ../../library/stdtypes.rst:3298 ../../library/stdtypes.rst:3389 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the instance." msgstr "" -#: ../../library/stdtypes.rst:3201 +#: ../../library/stdtypes.rst:3304 msgid "" "If you want to make the hex string easier to read, you can specify a single " "character separator *sep* parameter to include in the output. By default, " @@ -5109,13 +5258,13 @@ msgid "" "the separator position from the right, negative values from the left." msgstr "" -#: ../../library/stdtypes.rst:3218 +#: ../../library/stdtypes.rst:3321 msgid "" ":meth:`bytes.hex` now supports optional *sep* and *bytes_per_sep* parameters " "to insert separators between bytes in the hex output." msgstr "" -#: ../../library/stdtypes.rst:3222 +#: ../../library/stdtypes.rst:3325 msgid "" "Since bytes objects are sequences of integers (akin to a tuple), for a bytes " "object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be a bytes " @@ -5123,58 +5272,58 @@ msgid "" "and slicing will produce a string of length 1)" msgstr "" -#: ../../library/stdtypes.rst:3227 +#: ../../library/stdtypes.rst:3330 msgid "" "The representation of bytes objects uses the literal format (``b'...'``) " "since it is often more useful than e.g. ``bytes([46, 46, 46])``. You can " "always convert a bytes object into a list of integers using ``list(b)``." msgstr "" -#: ../../library/stdtypes.rst:3235 +#: ../../library/stdtypes.rst:3338 msgid "Bytearray Objects" msgstr "Bytearray 物件" -#: ../../library/stdtypes.rst:3239 +#: ../../library/stdtypes.rst:3342 msgid "" ":class:`bytearray` objects are a mutable counterpart to :class:`bytes` " "objects." msgstr "" -#: ../../library/stdtypes.rst:3245 +#: ../../library/stdtypes.rst:3348 msgid "" "There is no dedicated literal syntax for bytearray objects, instead they are " "always created by calling the constructor:" msgstr "" -#: ../../library/stdtypes.rst:3248 +#: ../../library/stdtypes.rst:3351 msgid "Creating an empty instance: ``bytearray()``" msgstr "建立一個空的實例:``bytearray()``" -#: ../../library/stdtypes.rst:3249 +#: ../../library/stdtypes.rst:3352 msgid "Creating a zero-filled instance with a given length: ``bytearray(10)``" msgstr "" -#: ../../library/stdtypes.rst:3250 +#: ../../library/stdtypes.rst:3353 msgid "From an iterable of integers: ``bytearray(range(20))``" msgstr "" -#: ../../library/stdtypes.rst:3251 +#: ../../library/stdtypes.rst:3354 msgid "" "Copying existing binary data via the buffer protocol: ``bytearray(b'Hi!')``" msgstr "" -#: ../../library/stdtypes.rst:3253 +#: ../../library/stdtypes.rst:3356 msgid "" "As bytearray objects are mutable, they support the :ref:`mutable ` sequence operations in addition to the common bytes and bytearray " "operations described in :ref:`bytes-methods`." msgstr "" -#: ../../library/stdtypes.rst:3257 +#: ../../library/stdtypes.rst:3360 msgid "Also see the :ref:`bytearray ` built-in." msgstr "另見內建的 :ref:`bytearray `。" -#: ../../library/stdtypes.rst:3259 +#: ../../library/stdtypes.rst:3362 msgid "" "Since 2 hexadecimal digits correspond precisely to a single byte, " "hexadecimal numbers are a commonly used format for describing binary data. " @@ -5182,64 +5331,64 @@ msgid "" "in that format:" msgstr "" -#: ../../library/stdtypes.rst:3265 +#: ../../library/stdtypes.rst:3368 msgid "" "This :class:`bytearray` class method returns bytearray object, decoding the " "given string object. The string must contain two hexadecimal digits per " "byte, with ASCII whitespace being ignored." msgstr "" -#: ../../library/stdtypes.rst:3272 +#: ../../library/stdtypes.rst:3375 msgid "" ":meth:`bytearray.fromhex` now skips all ASCII whitespace in the string, not " "just spaces." msgstr "" -#: ../../library/stdtypes.rst:3276 +#: ../../library/stdtypes.rst:3379 msgid "" ":meth:`bytearray.fromhex` now accepts ASCII :class:`bytes` and :term:`bytes-" "like objects ` as input." msgstr "" -#: ../../library/stdtypes.rst:3280 +#: ../../library/stdtypes.rst:3383 msgid "" "A reverse conversion function exists to transform a bytearray object into " "its hexadecimal representation." msgstr "" -#: ../../library/stdtypes.rst:3294 +#: ../../library/stdtypes.rst:3397 msgid "" "Similar to :meth:`bytes.hex`, :meth:`bytearray.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../library/stdtypes.rst:3301 +#: ../../library/stdtypes.rst:3404 msgid "" "Resize the :class:`bytearray` to contain *size* bytes. *size* must be " "greater than or equal to 0." msgstr "" -#: ../../library/stdtypes.rst:3304 +#: ../../library/stdtypes.rst:3407 msgid "" "If the :class:`bytearray` needs to shrink, bytes beyond *size* are truncated." msgstr "" -#: ../../library/stdtypes.rst:3306 +#: ../../library/stdtypes.rst:3409 msgid "" "If the :class:`bytearray` needs to grow, all new bytes, those beyond *size*, " "will be set to null bytes." msgstr "" -#: ../../library/stdtypes.rst:3310 +#: ../../library/stdtypes.rst:3413 msgid "This is equivalent to:" msgstr "等同於:" -#: ../../library/stdtypes.rst:3318 +#: ../../library/stdtypes.rst:3421 msgid "Examples:" msgstr "範例:" -#: ../../library/stdtypes.rst:3331 +#: ../../library/stdtypes.rst:3434 msgid "" "Since bytearray objects are sequences of integers (akin to a list), for a " "bytearray object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be " @@ -5247,7 +5396,7 @@ msgid "" "both indexing and slicing will produce a string of length 1)" msgstr "" -#: ../../library/stdtypes.rst:3336 +#: ../../library/stdtypes.rst:3439 msgid "" "The representation of bytearray objects uses the bytes literal format " "(``bytearray(b'...')``) since it is often more useful than e.g. " @@ -5255,11 +5404,11 @@ msgid "" "a list of integers using ``list(b)``." msgstr "" -#: ../../library/stdtypes.rst:3345 +#: ../../library/stdtypes.rst:3448 msgid "Bytes and Bytearray Operations" msgstr "Bytes 和 Bytearray 的操作" -#: ../../library/stdtypes.rst:3350 +#: ../../library/stdtypes.rst:3453 msgid "" "Both bytes and bytearray objects support the :ref:`common ` " "sequence operations. They interoperate not just with operands of the same " @@ -5268,14 +5417,14 @@ msgid "" "return type of the result may depend on the order of operands." msgstr "" -#: ../../library/stdtypes.rst:3358 +#: ../../library/stdtypes.rst:3461 msgid "" "The methods on bytes and bytearray objects don't accept strings as their " "arguments, just as the methods on strings don't accept bytes as their " "arguments. For example, you have to write::" msgstr "" -#: ../../library/stdtypes.rst:3362 +#: ../../library/stdtypes.rst:3465 msgid "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" @@ -5283,11 +5432,11 @@ msgstr "" "a = \"abc\"\n" "b = a.replace(\"a\", \"f\")" -#: ../../library/stdtypes.rst:3365 +#: ../../library/stdtypes.rst:3468 msgid "and::" msgstr "和: ::" -#: ../../library/stdtypes.rst:3367 +#: ../../library/stdtypes.rst:3470 msgid "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" @@ -5295,60 +5444,60 @@ msgstr "" "a = b\"abc\"\n" "b = a.replace(b\"a\", b\"f\")" -#: ../../library/stdtypes.rst:3370 +#: ../../library/stdtypes.rst:3473 msgid "" "Some bytes and bytearray operations assume the use of ASCII compatible " "binary formats, and hence should be avoided when working with arbitrary " "binary data. These restrictions are covered below." msgstr "" -#: ../../library/stdtypes.rst:3375 +#: ../../library/stdtypes.rst:3478 msgid "" "Using these ASCII based operations to manipulate binary data that is not " "stored in an ASCII based format may lead to data corruption." msgstr "" -#: ../../library/stdtypes.rst:3378 +#: ../../library/stdtypes.rst:3481 msgid "" "The following methods on bytes and bytearray objects can be used with " "arbitrary binary data." msgstr "" -#: ../../library/stdtypes.rst:3384 +#: ../../library/stdtypes.rst:3487 msgid "" "Return the number of non-overlapping occurrences of subsequence *sub* in the " "range [*start*, *end*]. Optional arguments *start* and *end* are " "interpreted as in slice notation." msgstr "" -#: ../../library/stdtypes.rst:3388 ../../library/stdtypes.rst:3493 -#: ../../library/stdtypes.rst:3515 ../../library/stdtypes.rst:3581 -#: ../../library/stdtypes.rst:3594 +#: ../../library/stdtypes.rst:3491 ../../library/stdtypes.rst:3596 +#: ../../library/stdtypes.rst:3618 ../../library/stdtypes.rst:3684 +#: ../../library/stdtypes.rst:3697 msgid "" "The subsequence to search for may be any :term:`bytes-like object` or an " "integer in the range 0 to 255." msgstr "" -#: ../../library/stdtypes.rst:3391 +#: ../../library/stdtypes.rst:3494 msgid "" "If *sub* is empty, returns the number of empty slices between characters " "which is the length of the bytes object plus one." msgstr "" -#: ../../library/stdtypes.rst:3394 ../../library/stdtypes.rst:3505 -#: ../../library/stdtypes.rst:3518 ../../library/stdtypes.rst:3584 -#: ../../library/stdtypes.rst:3597 +#: ../../library/stdtypes.rst:3497 ../../library/stdtypes.rst:3608 +#: ../../library/stdtypes.rst:3621 ../../library/stdtypes.rst:3687 +#: ../../library/stdtypes.rst:3700 msgid "Also accept an integer in the range 0 to 255 as the subsequence." msgstr "" -#: ../../library/stdtypes.rst:3401 +#: ../../library/stdtypes.rst:3504 msgid "" "If the binary data starts with the *prefix* string, return " "``bytes[len(prefix):]``. Otherwise, return a copy of the original binary " "data::" msgstr "" -#: ../../library/stdtypes.rst:3405 +#: ../../library/stdtypes.rst:3508 msgid "" ">>> b'TestHook'.removeprefix(b'Test')\n" "b'Hook'\n" @@ -5360,32 +5509,32 @@ msgstr "" ">>> b'BaseTestCase'.removeprefix(b'Test')\n" "b'BaseTestCase'" -#: ../../library/stdtypes.rst:3410 +#: ../../library/stdtypes.rst:3513 msgid "The *prefix* may be any :term:`bytes-like object`." msgstr "*prefix* 可以是任何的 :term:`bytes-like object`。" -#: ../../library/stdtypes.rst:3414 ../../library/stdtypes.rst:3436 -#: ../../library/stdtypes.rst:3569 ../../library/stdtypes.rst:3662 -#: ../../library/stdtypes.rst:3676 ../../library/stdtypes.rst:3706 -#: ../../library/stdtypes.rst:3720 ../../library/stdtypes.rst:3761 -#: ../../library/stdtypes.rst:3831 ../../library/stdtypes.rst:3849 -#: ../../library/stdtypes.rst:3877 ../../library/stdtypes.rst:4016 -#: ../../library/stdtypes.rst:4071 ../../library/stdtypes.rst:4114 -#: ../../library/stdtypes.rst:4135 ../../library/stdtypes.rst:4157 -#: ../../library/stdtypes.rst:4359 +#: ../../library/stdtypes.rst:3517 ../../library/stdtypes.rst:3539 +#: ../../library/stdtypes.rst:3672 ../../library/stdtypes.rst:3765 +#: ../../library/stdtypes.rst:3779 ../../library/stdtypes.rst:3809 +#: ../../library/stdtypes.rst:3823 ../../library/stdtypes.rst:3864 +#: ../../library/stdtypes.rst:3934 ../../library/stdtypes.rst:3952 +#: ../../library/stdtypes.rst:3980 ../../library/stdtypes.rst:4119 +#: ../../library/stdtypes.rst:4174 ../../library/stdtypes.rst:4217 +#: ../../library/stdtypes.rst:4238 ../../library/stdtypes.rst:4260 +#: ../../library/stdtypes.rst:4462 msgid "" "The bytearray version of this method does *not* operate in place - it always " "produces a new object, even if no changes were made." msgstr "" -#: ../../library/stdtypes.rst:3423 +#: ../../library/stdtypes.rst:3526 msgid "" "If the binary data ends with the *suffix* string and that *suffix* is not " "empty, return ``bytes[:-len(suffix)]``. Otherwise, return a copy of the " "original binary data::" msgstr "" -#: ../../library/stdtypes.rst:3427 +#: ../../library/stdtypes.rst:3530 msgid "" ">>> b'MiscTests'.removesuffix(b'Tests')\n" "b'Misc'\n" @@ -5397,15 +5546,15 @@ msgstr "" ">>> b'TmpDirMixin'.removesuffix(b'Tests')\n" "b'TmpDirMixin'" -#: ../../library/stdtypes.rst:3432 +#: ../../library/stdtypes.rst:3535 msgid "The *suffix* may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3445 +#: ../../library/stdtypes.rst:3548 msgid "Return the bytes decoded to a :class:`str`." msgstr "" -#: ../../library/stdtypes.rst:3450 +#: ../../library/stdtypes.rst:3553 msgid "" "*errors* controls how decoding errors are handled. If ``'strict'`` (the " "default), a :exc:`UnicodeError` exception is raised. Other possible values " @@ -5413,21 +5562,21 @@ msgid "" "`codecs.register_error`. See :ref:`error-handlers` for details." msgstr "" -#: ../../library/stdtypes.rst:3456 +#: ../../library/stdtypes.rst:3559 msgid "" "For performance reasons, the value of *errors* is not checked for validity " "unless a decoding error actually occurs, :ref:`devmode` is enabled or a :ref:" "`debug build ` is used." msgstr "" -#: ../../library/stdtypes.rst:3462 +#: ../../library/stdtypes.rst:3565 msgid "" "Passing the *encoding* argument to :class:`str` allows decoding any :term:" "`bytes-like object` directly, without needing to make a temporary :class:`!" "bytes` or :class:`!bytearray` object." msgstr "" -#: ../../library/stdtypes.rst:3477 +#: ../../library/stdtypes.rst:3580 msgid "" "Return ``True`` if the binary data ends with the specified *suffix*, " "otherwise return ``False``. *suffix* can also be a tuple of suffixes to " @@ -5435,11 +5584,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:3482 +#: ../../library/stdtypes.rst:3585 msgid "The suffix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3488 +#: ../../library/stdtypes.rst:3591 msgid "" "Return the lowest index in the data where the subsequence *sub* is found, " "such that *sub* is contained in the slice ``s[start:end]``. Optional " @@ -5447,14 +5596,14 @@ msgid "" "``-1`` if *sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:3498 +#: ../../library/stdtypes.rst:3601 msgid "" "The :meth:`~bytes.find` method should be used only if you need to know the " "position of *sub*. To check if *sub* is a substring or not, use the :" "keyword:`in` operator::" msgstr "" -#: ../../library/stdtypes.rst:3502 +#: ../../library/stdtypes.rst:3605 msgid "" ">>> b'Py' in b'Python'\n" "True" @@ -5462,13 +5611,13 @@ msgstr "" ">>> b'Py' in b'Python'\n" "True" -#: ../../library/stdtypes.rst:3512 +#: ../../library/stdtypes.rst:3615 msgid "" "Like :meth:`~bytes.find`, but raise :exc:`ValueError` when the subsequence " "is not found." msgstr "" -#: ../../library/stdtypes.rst:3525 +#: ../../library/stdtypes.rst:3628 msgid "" "Return a bytes or bytearray object which is the concatenation of the binary " "data sequences in *iterable*. A :exc:`TypeError` will be raised if there " @@ -5478,7 +5627,7 @@ msgid "" "method." msgstr "" -#: ../../library/stdtypes.rst:3536 +#: ../../library/stdtypes.rst:3639 msgid "" "This static method returns a translation table usable for :meth:`bytes." "translate` that will map each character in *from* into the character at the " @@ -5486,7 +5635,7 @@ msgid "" "objects ` and have the same length." msgstr "" -#: ../../library/stdtypes.rst:3547 +#: ../../library/stdtypes.rst:3650 msgid "" "Split the sequence at the first occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -5495,24 +5644,24 @@ msgid "" "by two empty bytes or bytearray objects." msgstr "" -#: ../../library/stdtypes.rst:3554 ../../library/stdtypes.rst:3611 +#: ../../library/stdtypes.rst:3657 ../../library/stdtypes.rst:3714 msgid "The separator to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3560 +#: ../../library/stdtypes.rst:3663 msgid "" "Return a copy of the sequence with all occurrences of subsequence *old* " "replaced by *new*. If the optional argument *count* is given, only the " "first *count* occurrences are replaced." msgstr "" -#: ../../library/stdtypes.rst:3564 +#: ../../library/stdtypes.rst:3667 msgid "" "The subsequence to search for and its replacement may be any :term:`bytes-" "like object`." msgstr "" -#: ../../library/stdtypes.rst:3576 +#: ../../library/stdtypes.rst:3679 msgid "" "Return the highest index in the sequence where the subsequence *sub* is " "found, such that *sub* is contained within ``s[start:end]``. Optional " @@ -5520,13 +5669,13 @@ msgid "" "``-1`` on failure." msgstr "" -#: ../../library/stdtypes.rst:3591 +#: ../../library/stdtypes.rst:3694 msgid "" "Like :meth:`~bytes.rfind` but raises :exc:`ValueError` when the subsequence " "*sub* is not found." msgstr "" -#: ../../library/stdtypes.rst:3604 +#: ../../library/stdtypes.rst:3707 msgid "" "Split the sequence at the last occurrence of *sep*, and return a 3-tuple " "containing the part before the separator, the separator itself or its " @@ -5535,7 +5684,7 @@ msgid "" "followed by a copy of the original sequence." msgstr "" -#: ../../library/stdtypes.rst:3617 +#: ../../library/stdtypes.rst:3720 msgid "" "Return ``True`` if the binary data starts with the specified *prefix*, " "otherwise return ``False``. *prefix* can also be a tuple of prefixes to " @@ -5543,11 +5692,11 @@ msgid "" "optional *end*, stop comparing at that position." msgstr "" -#: ../../library/stdtypes.rst:3622 +#: ../../library/stdtypes.rst:3725 msgid "The prefix(es) to search for may be any :term:`bytes-like object`." msgstr "" -#: ../../library/stdtypes.rst:3628 +#: ../../library/stdtypes.rst:3731 msgid "" "Return a copy of the bytes or bytearray object where all bytes occurring in " "the optional argument *delete* are removed, and the remaining bytes have " @@ -5555,18 +5704,18 @@ msgid "" "object of length 256." msgstr "" -#: ../../library/stdtypes.rst:3633 +#: ../../library/stdtypes.rst:3736 msgid "" "You can use the :func:`bytes.maketrans` method to create a translation table." msgstr "" -#: ../../library/stdtypes.rst:3636 +#: ../../library/stdtypes.rst:3739 msgid "" "Set the *table* argument to ``None`` for translations that only delete " "characters::" msgstr "" -#: ../../library/stdtypes.rst:3639 +#: ../../library/stdtypes.rst:3742 msgid "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" @@ -5574,11 +5723,11 @@ msgstr "" ">>> b'read this short text'.translate(None, b'aeiou')\n" "b'rd ths shrt txt'" -#: ../../library/stdtypes.rst:3642 +#: ../../library/stdtypes.rst:3745 msgid "*delete* is now supported as a keyword argument." msgstr "支援 *delete* 關鍵字引數。" -#: ../../library/stdtypes.rst:3646 +#: ../../library/stdtypes.rst:3749 msgid "" "The following methods on bytes and bytearray objects have default behaviours " "that assume the use of ASCII compatible binary formats, but can still be " @@ -5587,7 +5736,7 @@ msgid "" "instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:3655 +#: ../../library/stdtypes.rst:3758 msgid "" "Return a copy of the object centered in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5595,7 +5744,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3669 +#: ../../library/stdtypes.rst:3772 msgid "" "Return a copy of the object left justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5603,7 +5752,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3683 +#: ../../library/stdtypes.rst:3786 msgid "" "Return a copy of the sequence with specified leading bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -5612,7 +5761,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3689 +#: ../../library/stdtypes.rst:3792 msgid "" ">>> b' spacious '.lstrip()\n" "b'spacious '\n" @@ -5624,14 +5773,14 @@ msgstr "" ">>> b'www.example.com'.lstrip(b'cmowz.')\n" "b'example.com'" -#: ../../library/stdtypes.rst:3694 +#: ../../library/stdtypes.rst:3797 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removeprefix` for a method that will remove a " "single prefix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3699 +#: ../../library/stdtypes.rst:3802 msgid "" ">>> b'Arthur: three!'.lstrip(b'Arthur: ')\n" "b'ee!'\n" @@ -5643,7 +5792,7 @@ msgstr "" ">>> b'Arthur: three!'.removeprefix(b'Arthur: ')\n" "b'three!'" -#: ../../library/stdtypes.rst:3713 +#: ../../library/stdtypes.rst:3816 msgid "" "Return a copy of the object right justified in a sequence of length *width*. " "Padding is done using the specified *fillbyte* (default is an ASCII space). " @@ -5651,7 +5800,7 @@ msgid "" "less than or equal to ``len(s)``." msgstr "" -#: ../../library/stdtypes.rst:3727 +#: ../../library/stdtypes.rst:3830 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are " @@ -5661,7 +5810,7 @@ msgid "" "described in detail below." msgstr "" -#: ../../library/stdtypes.rst:3738 +#: ../../library/stdtypes.rst:3841 msgid "" "Return a copy of the sequence with specified trailing bytes removed. The " "*bytes* argument is a binary sequence specifying the set of byte values to " @@ -5670,7 +5819,7 @@ msgid "" "all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3744 +#: ../../library/stdtypes.rst:3847 msgid "" ">>> b' spacious '.rstrip()\n" "b' spacious'\n" @@ -5682,14 +5831,14 @@ msgstr "" ">>> b'mississippi'.rstrip(b'ipz')\n" "b'mississ'" -#: ../../library/stdtypes.rst:3749 +#: ../../library/stdtypes.rst:3852 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`. See :meth:`~bytes.removesuffix` for a method that will remove a " "single suffix string rather than all of a set of characters. For example::" msgstr "" -#: ../../library/stdtypes.rst:3754 +#: ../../library/stdtypes.rst:3857 msgid "" ">>> b'Monty Python'.rstrip(b' Python')\n" "b'M'\n" @@ -5701,7 +5850,7 @@ msgstr "" ">>> b'Monty Python'.removesuffix(b' Python')\n" "b'Monty'" -#: ../../library/stdtypes.rst:3768 +#: ../../library/stdtypes.rst:3871 msgid "" "Split the binary sequence into subsequences of the same type, using *sep* as " "the delimiter string. If *maxsplit* is given and non-negative, at most " @@ -5710,7 +5859,7 @@ msgid "" "limit on the number of splits (all possible splits are made)." msgstr "" -#: ../../library/stdtypes.rst:3774 +#: ../../library/stdtypes.rst:3877 msgid "" "If *sep* is given, consecutive delimiters are not grouped together and are " "deemed to delimit empty subsequences (for example, ``b'1,,2'.split(b',')`` " @@ -5721,7 +5870,7 @@ msgid "" "like object`." msgstr "" -#: ../../library/stdtypes.rst:3784 +#: ../../library/stdtypes.rst:3887 msgid "" ">>> b'1,2,3'.split(b',')\n" "[b'1', b'2', b'3']\n" @@ -5741,7 +5890,7 @@ msgstr "" ">>> b'1<>2<>3<4'.split(b'<>')\n" "[b'1', b'2', b'3<4']" -#: ../../library/stdtypes.rst:3793 +#: ../../library/stdtypes.rst:3896 msgid "" "If *sep* is not specified or is ``None``, a different splitting algorithm is " "applied: runs of consecutive ASCII whitespace are regarded as a single " @@ -5751,7 +5900,7 @@ msgid "" "without a specified separator returns ``[]``." msgstr "" -#: ../../library/stdtypes.rst:3803 +#: ../../library/stdtypes.rst:3906 msgid "" ">>> b'1 2 3'.split()\n" "[b'1', b'2', b'3']\n" @@ -5767,7 +5916,7 @@ msgstr "" ">>> b' 1 2 3 '.split()\n" "[b'1', b'2', b'3']" -#: ../../library/stdtypes.rst:3814 +#: ../../library/stdtypes.rst:3917 msgid "" "Return a copy of the sequence with specified leading and trailing bytes " "removed. The *bytes* argument is a binary sequence specifying the set of " @@ -5776,7 +5925,7 @@ msgid "" "or suffix; rather, all combinations of its values are stripped::" msgstr "" -#: ../../library/stdtypes.rst:3821 +#: ../../library/stdtypes.rst:3924 msgid "" ">>> b' spacious '.strip()\n" "b'spacious'\n" @@ -5788,13 +5937,13 @@ msgstr "" ">>> b'www.example.com'.strip(b'cmowz.')\n" "b'example'" -#: ../../library/stdtypes.rst:3826 +#: ../../library/stdtypes.rst:3929 msgid "" "The binary sequence of byte values to remove may be any :term:`bytes-like " "object`." msgstr "" -#: ../../library/stdtypes.rst:3835 +#: ../../library/stdtypes.rst:3938 msgid "" "The following methods on bytes and bytearray objects assume the use of ASCII " "compatible binary formats and should not be applied to arbitrary binary " @@ -5802,14 +5951,14 @@ msgid "" "operate in place, and instead produce new objects." msgstr "" -#: ../../library/stdtypes.rst:3843 +#: ../../library/stdtypes.rst:3946 msgid "" "Return a copy of the sequence with each byte interpreted as an ASCII " "character, and the first byte capitalized and the rest lowercased. Non-ASCII " "byte values are passed through unchanged." msgstr "" -#: ../../library/stdtypes.rst:3856 +#: ../../library/stdtypes.rst:3959 msgid "" "Return a copy of the sequence where all ASCII tab characters are replaced by " "one or more ASCII spaces, depending on the current column and the given tab " @@ -5825,7 +5974,7 @@ msgid "" "by one regardless of how the byte value is represented when printed::" msgstr "" -#: ../../library/stdtypes.rst:3870 +#: ../../library/stdtypes.rst:3973 msgid "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs()\n" "b'01 012 0123 01234'\n" @@ -5837,7 +5986,7 @@ msgstr "" ">>> b'01\\t012\\t0123\\t01234'.expandtabs(4)\n" "b'01 012 0123 01234'" -#: ../../library/stdtypes.rst:3884 +#: ../../library/stdtypes.rst:3987 msgid "" "Return ``True`` if all bytes in the sequence are alphabetical ASCII " "characters or ASCII decimal digits and the sequence is not empty, ``False`` " @@ -5846,7 +5995,7 @@ msgid "" "digits are those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:3892 +#: ../../library/stdtypes.rst:3995 msgid "" ">>> b'ABCabc1'.isalnum()\n" "True\n" @@ -5858,7 +6007,7 @@ msgstr "" ">>> b'ABC abc1'.isalnum()\n" "False" -#: ../../library/stdtypes.rst:3901 +#: ../../library/stdtypes.rst:4004 msgid "" "Return ``True`` if all bytes in the sequence are alphabetic ASCII characters " "and the sequence is not empty, ``False`` otherwise. Alphabetic ASCII " @@ -5866,7 +6015,7 @@ msgid "" "``b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:3908 +#: ../../library/stdtypes.rst:4011 msgid "" ">>> b'ABCabc'.isalpha()\n" "True\n" @@ -5878,20 +6027,20 @@ msgstr "" ">>> b'ABCabc1'.isalpha()\n" "False" -#: ../../library/stdtypes.rst:3917 +#: ../../library/stdtypes.rst:4020 msgid "" "Return ``True`` if the sequence is empty or all bytes in the sequence are " "ASCII, ``False`` otherwise. ASCII bytes are in the range 0-0x7F." msgstr "" -#: ../../library/stdtypes.rst:3927 +#: ../../library/stdtypes.rst:4030 msgid "" "Return ``True`` if all bytes in the sequence are ASCII decimal digits and " "the sequence is not empty, ``False`` otherwise. ASCII decimal digits are " "those byte values in the sequence ``b'0123456789'``." msgstr "" -#: ../../library/stdtypes.rst:3933 +#: ../../library/stdtypes.rst:4036 msgid "" ">>> b'1234'.isdigit()\n" "True\n" @@ -5903,13 +6052,13 @@ msgstr "" ">>> b'1.23'.isdigit()\n" "False" -#: ../../library/stdtypes.rst:3942 +#: ../../library/stdtypes.rst:4045 msgid "" "Return ``True`` if there is at least one lowercase ASCII character in the " "sequence and no uppercase ASCII characters, ``False`` otherwise." msgstr "" -#: ../../library/stdtypes.rst:3947 +#: ../../library/stdtypes.rst:4050 msgid "" ">>> b'hello world'.islower()\n" "True\n" @@ -5921,16 +6070,16 @@ msgstr "" ">>> b'Hello world'.islower()\n" "False" -#: ../../library/stdtypes.rst:3952 ../../library/stdtypes.rst:3994 -#: ../../library/stdtypes.rst:4010 ../../library/stdtypes.rst:4060 -#: ../../library/stdtypes.rst:4129 +#: ../../library/stdtypes.rst:4055 ../../library/stdtypes.rst:4097 +#: ../../library/stdtypes.rst:4113 ../../library/stdtypes.rst:4163 +#: ../../library/stdtypes.rst:4232 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " "values in the sequence ``b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'``." msgstr "" -#: ../../library/stdtypes.rst:3960 +#: ../../library/stdtypes.rst:4063 msgid "" "Return ``True`` if all bytes in the sequence are ASCII whitespace and the " "sequence is not empty, ``False`` otherwise. ASCII whitespace characters are " @@ -5938,14 +6087,14 @@ msgid "" "newline, carriage return, vertical tab, form feed)." msgstr "" -#: ../../library/stdtypes.rst:3969 +#: ../../library/stdtypes.rst:4072 msgid "" "Return ``True`` if the sequence is ASCII titlecase and the sequence is not " "empty, ``False`` otherwise. See :meth:`bytes.title` for more details on the " "definition of \"titlecase\"." msgstr "" -#: ../../library/stdtypes.rst:3975 +#: ../../library/stdtypes.rst:4078 msgid "" ">>> b'Hello World'.istitle()\n" "True\n" @@ -5957,14 +6106,14 @@ msgstr "" ">>> b'Hello world'.istitle()\n" "False" -#: ../../library/stdtypes.rst:3984 +#: ../../library/stdtypes.rst:4087 msgid "" "Return ``True`` if there is at least one uppercase alphabetic ASCII " "character in the sequence and no lowercase ASCII characters, ``False`` " "otherwise." msgstr "" -#: ../../library/stdtypes.rst:3989 +#: ../../library/stdtypes.rst:4092 msgid "" ">>> b'HELLO WORLD'.isupper()\n" "True\n" @@ -5976,13 +6125,13 @@ msgstr "" ">>> b'Hello world'.isupper()\n" "False" -#: ../../library/stdtypes.rst:4002 +#: ../../library/stdtypes.rst:4105 msgid "" "Return a copy of the sequence with all the uppercase ASCII characters " "converted to their corresponding lowercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:4007 +#: ../../library/stdtypes.rst:4110 msgid "" ">>> b'Hello World'.lower()\n" "b'hello world'" @@ -5990,7 +6139,7 @@ msgstr "" ">>> b'Hello World'.lower()\n" "b'hello world'" -#: ../../library/stdtypes.rst:4027 +#: ../../library/stdtypes.rst:4130 msgid "" "Return a list of the lines in the binary sequence, breaking at ASCII line " "boundaries. This method uses the :term:`universal newlines` approach to " @@ -5998,7 +6147,7 @@ msgid "" "*keepends* is given and true." msgstr "" -#: ../../library/stdtypes.rst:4034 +#: ../../library/stdtypes.rst:4137 msgid "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines()\n" "[b'ab c', b'', b'de fg', b'kl']\n" @@ -6010,14 +6159,14 @@ msgstr "" ">>> b'ab c\\n\\nde fg\\rkl\\r\\n'.splitlines(keepends=True)\n" "[b'ab c\\n', b'\\n', b'de fg\\r', b'kl\\r\\n']" -#: ../../library/stdtypes.rst:4039 +#: ../../library/stdtypes.rst:4142 msgid "" "Unlike :meth:`~bytes.split` when a delimiter string *sep* is given, this " "method returns an empty list for the empty string, and a terminal line break " "does not result in an extra line::" msgstr "" -#: ../../library/stdtypes.rst:4043 +#: ../../library/stdtypes.rst:4146 msgid "" ">>> b\"\".split(b'\\n'), b\"Two lines\\n\".split(b'\\n')\n" "([b''], [b'Two lines', b''])\n" @@ -6029,13 +6178,13 @@ msgstr "" ">>> b\"\".splitlines(), b\"One line\\n\".splitlines()\n" "([], [b'One line'])" -#: ../../library/stdtypes.rst:4052 +#: ../../library/stdtypes.rst:4155 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart and vice-versa." msgstr "" -#: ../../library/stdtypes.rst:4057 +#: ../../library/stdtypes.rst:4160 msgid "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" @@ -6043,7 +6192,7 @@ msgstr "" ">>> b'Hello World'.swapcase()\n" "b'hELLO wORLD'" -#: ../../library/stdtypes.rst:4064 +#: ../../library/stdtypes.rst:4167 msgid "" "Unlike :func:`str.swapcase`, it is always the case that ``bin.swapcase()." "swapcase() == bin`` for the binary versions. Case conversions are " @@ -6051,14 +6200,14 @@ msgid "" "Unicode code points." msgstr "" -#: ../../library/stdtypes.rst:4078 +#: ../../library/stdtypes.rst:4181 msgid "" "Return a titlecased version of the binary sequence where words start with an " "uppercase ASCII character and the remaining characters are lowercase. " "Uncased byte values are left unmodified." msgstr "" -#: ../../library/stdtypes.rst:4084 +#: ../../library/stdtypes.rst:4187 msgid "" ">>> b'Hello world'.title()\n" "b'Hello World'" @@ -6066,7 +6215,7 @@ msgstr "" ">>> b'Hello world'.title()\n" "b'Hello World'" -#: ../../library/stdtypes.rst:4087 +#: ../../library/stdtypes.rst:4190 msgid "" "Lowercase ASCII characters are those byte values in the sequence " "``b'abcdefghijklmnopqrstuvwxyz'``. Uppercase ASCII characters are those byte " @@ -6074,7 +6223,7 @@ msgid "" "values are uncased." msgstr "" -#: ../../library/stdtypes.rst:4097 +#: ../../library/stdtypes.rst:4200 msgid "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" @@ -6082,12 +6231,12 @@ msgstr "" ">>> b\"they're bill's friends from the UK\".title()\n" "b\"They'Re Bill'S Friends From The Uk\"" -#: ../../library/stdtypes.rst:4100 +#: ../../library/stdtypes.rst:4203 msgid "" "A workaround for apostrophes can be constructed using regular expressions::" msgstr "" -#: ../../library/stdtypes.rst:4102 +#: ../../library/stdtypes.rst:4205 msgid "" ">>> import re\n" ">>> def titlecase(s):\n" @@ -6109,13 +6258,13 @@ msgstr "" ">>> titlecase(b\"they're bill's friends.\")\n" "b\"They're Bill's Friends.\"" -#: ../../library/stdtypes.rst:4121 +#: ../../library/stdtypes.rst:4224 msgid "" "Return a copy of the sequence with all the lowercase ASCII characters " "converted to their corresponding uppercase counterpart." msgstr "" -#: ../../library/stdtypes.rst:4126 +#: ../../library/stdtypes.rst:4229 msgid "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" @@ -6123,7 +6272,7 @@ msgstr "" ">>> b'Hello World'.upper()\n" "b'HELLO WORLD'" -#: ../../library/stdtypes.rst:4142 +#: ../../library/stdtypes.rst:4245 msgid "" "Return a copy of the sequence left filled with ASCII ``b'0'`` digits to make " "a sequence of length *width*. A leading sign prefix (``b'+'``/ ``b'-'``) is " @@ -6132,7 +6281,7 @@ msgid "" "*width* is less than or equal to ``len(seq)``." msgstr "" -#: ../../library/stdtypes.rst:4150 +#: ../../library/stdtypes.rst:4253 msgid "" ">>> b\"42\".zfill(5)\n" "b'00042'\n" @@ -6144,11 +6293,11 @@ msgstr "" ">>> b\"-42\".zfill(5)\n" "b'-0042'" -#: ../../library/stdtypes.rst:4164 +#: ../../library/stdtypes.rst:4267 msgid "``printf``-style Bytes Formatting" msgstr "" -#: ../../library/stdtypes.rst:4181 +#: ../../library/stdtypes.rst:4284 msgid "" "The formatting operations described here exhibit a variety of quirks that " "lead to a number of common errors (such as failing to display tuples and " @@ -6156,7 +6305,7 @@ msgid "" "dictionary, wrap it in a tuple." msgstr "" -#: ../../library/stdtypes.rst:4186 +#: ../../library/stdtypes.rst:4289 msgid "" "Bytes objects (``bytes``/``bytearray``) have one unique built-in operation: " "the ``%`` operator (modulo). This is also known as the bytes *formatting* or " @@ -6166,7 +6315,7 @@ msgid "" "func:`sprintf` in the C language." msgstr "" -#: ../../library/stdtypes.rst:4193 +#: ../../library/stdtypes.rst:4296 msgid "" "If *format* requires a single argument, *values* may be a single non-tuple " "object. [5]_ Otherwise, *values* must be a tuple with exactly the number of " @@ -6174,7 +6323,7 @@ msgid "" "example, a dictionary)." msgstr "" -#: ../../library/stdtypes.rst:4227 +#: ../../library/stdtypes.rst:4330 msgid "" "When the right argument is a dictionary (or other mapping type), then the " "formats in the bytes object *must* include a parenthesised mapping key into " @@ -6182,77 +6331,77 @@ msgid "" "mapping key selects the value to be formatted from the mapping. For example:" msgstr "" -#: ../../library/stdtypes.rst:4279 +#: ../../library/stdtypes.rst:4382 msgid "\\(8)" msgstr "\\(8)" -#: ../../library/stdtypes.rst:4301 +#: ../../library/stdtypes.rst:4404 msgid "Single byte (accepts integer or single byte objects)." msgstr "" -#: ../../library/stdtypes.rst:4304 +#: ../../library/stdtypes.rst:4407 msgid "``'b'``" msgstr "``'b'``" -#: ../../library/stdtypes.rst:4304 +#: ../../library/stdtypes.rst:4407 msgid "" "Bytes (any object that follows the :ref:`buffer protocol ` or " "has :meth:`~object.__bytes__`)." msgstr "" -#: ../../library/stdtypes.rst:4308 +#: ../../library/stdtypes.rst:4411 msgid "" "``'s'`` is an alias for ``'b'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:4311 +#: ../../library/stdtypes.rst:4414 msgid "" "Bytes (converts any Python object using ``repr(obj).encode('ascii', " "'backslashreplace')``)." msgstr "" -#: ../../library/stdtypes.rst:4314 +#: ../../library/stdtypes.rst:4417 msgid "" "``'r'`` is an alias for ``'a'`` and should only be used for Python2/3 code " "bases." msgstr "" -#: ../../library/stdtypes.rst:4314 +#: ../../library/stdtypes.rst:4417 msgid "\\(7)" msgstr "\\(7)" -#: ../../library/stdtypes.rst:4349 +#: ../../library/stdtypes.rst:4452 msgid "``b'%s'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%s'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../library/stdtypes.rst:4352 +#: ../../library/stdtypes.rst:4455 msgid "``b'%r'`` is deprecated, but will not be removed during the 3.x series." msgstr "``b'%r'`` 已被棄用,但在 3.x 系列中不會被移除。" -#: ../../library/stdtypes.rst:4364 +#: ../../library/stdtypes.rst:4467 msgid ":pep:`461` - Adding % formatting to bytes and bytearray" msgstr "" -#: ../../library/stdtypes.rst:4371 +#: ../../library/stdtypes.rst:4474 msgid "Memory Views" msgstr "" -#: ../../library/stdtypes.rst:4373 +#: ../../library/stdtypes.rst:4476 msgid "" ":class:`memoryview` objects allow Python code to access the internal data of " "an object that supports the :ref:`buffer protocol ` without " "copying." msgstr "" -#: ../../library/stdtypes.rst:4379 +#: ../../library/stdtypes.rst:4482 msgid "" "Create a :class:`memoryview` that references *object*. *object* must " "support the buffer protocol. Built-in objects that support the buffer " "protocol include :class:`bytes` and :class:`bytearray`." msgstr "" -#: ../../library/stdtypes.rst:4383 +#: ../../library/stdtypes.rst:4486 msgid "" "A :class:`memoryview` has the notion of an *element*, which is the atomic " "memory unit handled by the originating *object*. For many simple types such " @@ -6260,32 +6409,32 @@ msgid "" "other types such as :class:`array.array` may have bigger elements." msgstr "" -#: ../../library/stdtypes.rst:4388 +#: ../../library/stdtypes.rst:4491 msgid "" "``len(view)`` is equal to the length of :class:`~memoryview.tolist`, which " "is the nested list representation of the view. If ``view.ndim = 1``, this is " "equal to the number of elements in the view." msgstr "" -#: ../../library/stdtypes.rst:4392 +#: ../../library/stdtypes.rst:4495 msgid "" "If ``view.ndim == 0``, ``len(view)`` now raises :exc:`TypeError` instead of " "returning 1." msgstr "" -#: ../../library/stdtypes.rst:4395 +#: ../../library/stdtypes.rst:4498 msgid "" "The :class:`~memoryview.itemsize` attribute will give you the number of " "bytes in a single element." msgstr "" -#: ../../library/stdtypes.rst:4398 +#: ../../library/stdtypes.rst:4501 msgid "" "A :class:`memoryview` supports slicing and indexing to expose its data. One-" "dimensional slicing will result in a subview::" msgstr "" -#: ../../library/stdtypes.rst:4401 +#: ../../library/stdtypes.rst:4504 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> v[1]\n" @@ -6307,7 +6456,7 @@ msgstr "" ">>> bytes(v[1:4])\n" "b'bce'" -#: ../../library/stdtypes.rst:4411 +#: ../../library/stdtypes.rst:4514 msgid "" "If :class:`~memoryview.format` is one of the native format specifiers from " "the :mod:`struct` module, indexing with an integer or a tuple of integers is " @@ -6318,11 +6467,11 @@ msgid "" "memoryviews can be indexed with the empty tuple." msgstr "" -#: ../../library/stdtypes.rst:4420 +#: ../../library/stdtypes.rst:4523 msgid "Here is an example with a non-byte format::" msgstr "" -#: ../../library/stdtypes.rst:4422 +#: ../../library/stdtypes.rst:4525 msgid "" ">>> import array\n" ">>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])\n" @@ -6344,13 +6493,13 @@ msgstr "" ">>> m[::2].tolist()\n" "[-11111111, -33333333]" -#: ../../library/stdtypes.rst:4432 +#: ../../library/stdtypes.rst:4535 msgid "" "If the underlying object is writable, the memoryview supports one-" "dimensional slice assignment. Resizing is not allowed::" msgstr "" -#: ../../library/stdtypes.rst:4435 +#: ../../library/stdtypes.rst:4538 msgid "" ">>> data = bytearray(b'abcefg')\n" ">>> v = memoryview(data)\n" @@ -6390,14 +6539,14 @@ msgstr "" ">>> data\n" "bytearray(b'z1spam')" -#: ../../library/stdtypes.rst:4453 +#: ../../library/stdtypes.rst:4556 msgid "" "One-dimensional memoryviews of :term:`hashable` (read-only) types with " "formats 'B', 'b' or 'c' are also hashable. The hash is defined as ``hash(m) " "== hash(m.tobytes())``::" msgstr "" -#: ../../library/stdtypes.rst:4457 +#: ../../library/stdtypes.rst:4560 msgid "" ">>> v = memoryview(b'abcefg')\n" ">>> hash(v) == hash(b'abcefg')\n" @@ -6415,44 +6564,44 @@ msgstr "" ">>> hash(v[::-2]) == hash(b'abcefg'[::-2])\n" "True" -#: ../../library/stdtypes.rst:4465 +#: ../../library/stdtypes.rst:4568 msgid "" "One-dimensional memoryviews can now be sliced. One-dimensional memoryviews " "with formats 'B', 'b' or 'c' are now :term:`hashable`." msgstr "" -#: ../../library/stdtypes.rst:4469 +#: ../../library/stdtypes.rst:4572 msgid "" "memoryview is now registered automatically with :class:`collections.abc." "Sequence`" msgstr "" -#: ../../library/stdtypes.rst:4473 +#: ../../library/stdtypes.rst:4576 msgid "memoryviews can now be indexed with tuple of integers." msgstr "" -#: ../../library/stdtypes.rst:4476 +#: ../../library/stdtypes.rst:4579 msgid "memoryview is now a :term:`generic type`." msgstr "" -#: ../../library/stdtypes.rst:4479 +#: ../../library/stdtypes.rst:4582 msgid ":class:`memoryview` has several methods:" msgstr ":class:`memoryview` 有幾個方法:" -#: ../../library/stdtypes.rst:4483 +#: ../../library/stdtypes.rst:4586 msgid "" "A memoryview and a :pep:`3118` exporter are equal if their shapes are " "equivalent and if all corresponding values are equal when the operands' " "respective format codes are interpreted using :mod:`struct` syntax." msgstr "" -#: ../../library/stdtypes.rst:4487 +#: ../../library/stdtypes.rst:4590 msgid "" "For the subset of :mod:`struct` format strings currently supported by :meth:" "`tolist`, ``v`` and ``w`` are equal if ``v.tolist() == w.tolist()``::" msgstr "" -#: ../../library/stdtypes.rst:4490 +#: ../../library/stdtypes.rst:4593 msgid "" ">>> import array\n" ">>> a = array.array('I', [1, 2, 3, 4, 5])\n" @@ -6486,14 +6635,14 @@ msgstr "" ">>> z.tolist() == c.tolist()\n" "True" -#: ../../library/stdtypes.rst:4506 +#: ../../library/stdtypes.rst:4609 msgid "" "If either format string is not supported by the :mod:`struct` module, then " "the objects will always compare as unequal (even if the format strings and " "buffer contents are identical)::" msgstr "" -#: ../../library/stdtypes.rst:4510 +#: ../../library/stdtypes.rst:4613 msgid "" ">>> from ctypes import BigEndianStructure, c_long\n" ">>> class BEPoint(BigEndianStructure):\n" @@ -6519,25 +6668,25 @@ msgstr "" ">>> a == b\n" "False" -#: ../../library/stdtypes.rst:4522 +#: ../../library/stdtypes.rst:4625 msgid "" "Note that, as with floating-point numbers, ``v is w`` does *not* imply ``v " "== w`` for memoryview objects." msgstr "" -#: ../../library/stdtypes.rst:4525 +#: ../../library/stdtypes.rst:4628 msgid "" "Previous versions compared the raw memory disregarding the item format and " "the logical array structure." msgstr "" -#: ../../library/stdtypes.rst:4531 +#: ../../library/stdtypes.rst:4634 msgid "" "Return the data in the buffer as a bytestring. This is equivalent to " "calling the :class:`bytes` constructor on the memoryview. ::" msgstr "" -#: ../../library/stdtypes.rst:4534 +#: ../../library/stdtypes.rst:4637 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.tobytes()\n" @@ -6551,7 +6700,7 @@ msgstr "" ">>> bytes(m)\n" "b'abc'" -#: ../../library/stdtypes.rst:4540 +#: ../../library/stdtypes.rst:4643 msgid "" "For non-contiguous arrays the result is equal to the flattened list " "representation with all elements converted to bytes. :meth:`tobytes` " @@ -6559,7 +6708,7 @@ msgid "" "module syntax." msgstr "" -#: ../../library/stdtypes.rst:4545 +#: ../../library/stdtypes.rst:4648 msgid "" "*order* can be {'C', 'F', 'A'}. When *order* is 'C' or 'F', the data of the " "original array is converted to C or Fortran order. For contiguous views, 'A' " @@ -6568,13 +6717,13 @@ msgid "" "to C first. *order=None* is the same as *order='C'*." msgstr "" -#: ../../library/stdtypes.rst:4555 +#: ../../library/stdtypes.rst:4658 msgid "" "Return a string object containing two hexadecimal digits for each byte in " "the buffer. ::" msgstr "" -#: ../../library/stdtypes.rst:4558 +#: ../../library/stdtypes.rst:4661 msgid "" ">>> m = memoryview(b\"abc\")\n" ">>> m.hex()\n" @@ -6584,18 +6733,18 @@ msgstr "" ">>> m.hex()\n" "'616263'" -#: ../../library/stdtypes.rst:4564 +#: ../../library/stdtypes.rst:4667 msgid "" "Similar to :meth:`bytes.hex`, :meth:`memoryview.hex` now supports optional " "*sep* and *bytes_per_sep* parameters to insert separators between bytes in " "the hex output." msgstr "" -#: ../../library/stdtypes.rst:4571 +#: ../../library/stdtypes.rst:4674 msgid "Return the data in the buffer as a list of elements. ::" msgstr "" -#: ../../library/stdtypes.rst:4573 +#: ../../library/stdtypes.rst:4676 msgid "" ">>> memoryview(b'abc').tolist()\n" "[97, 98, 99]\n" @@ -6613,19 +6762,19 @@ msgstr "" ">>> m.tolist()\n" "[1.1, 2.2, 3.3]" -#: ../../library/stdtypes.rst:4581 +#: ../../library/stdtypes.rst:4684 msgid "" ":meth:`tolist` now supports all single character native formats in :mod:" "`struct` module syntax as well as multi-dimensional representations." msgstr "" -#: ../../library/stdtypes.rst:4588 +#: ../../library/stdtypes.rst:4691 msgid "" "Return a readonly version of the memoryview object. The original memoryview " "object is unchanged. ::" msgstr "" -#: ../../library/stdtypes.rst:4591 +#: ../../library/stdtypes.rst:4694 msgid "" ">>> m = memoryview(bytearray(b'abc'))\n" ">>> mm = m.toreadonly()\n" @@ -6651,7 +6800,7 @@ msgstr "" ">>> mm.tolist()\n" "[43, 98, 99]" -#: ../../library/stdtypes.rst:4607 +#: ../../library/stdtypes.rst:4710 msgid "" "Release the underlying buffer exposed by the memoryview object. Many " "objects take special actions when a view is held on them (for example, a :" @@ -6660,14 +6809,14 @@ msgid "" "resources) as soon as possible." msgstr "" -#: ../../library/stdtypes.rst:4613 +#: ../../library/stdtypes.rst:4716 msgid "" "After this method has been called, any further operation on the view raises " "a :class:`ValueError` (except :meth:`release` itself which can be called " "multiple times)::" msgstr "" -#: ../../library/stdtypes.rst:4617 +#: ../../library/stdtypes.rst:4720 msgid "" ">>> m = memoryview(b'abc')\n" ">>> m.release()\n" @@ -6683,13 +6832,13 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../library/stdtypes.rst:4624 +#: ../../library/stdtypes.rst:4727 msgid "" "The context management protocol can be used for a similar effect, using the " "``with`` statement::" msgstr "" -#: ../../library/stdtypes.rst:4627 +#: ../../library/stdtypes.rst:4730 msgid "" ">>> with memoryview(b'abc') as m:\n" "... m[0]\n" @@ -6709,7 +6858,7 @@ msgstr "" " File \"\", line 1, in \n" "ValueError: operation forbidden on released memoryview object" -#: ../../library/stdtypes.rst:4641 +#: ../../library/stdtypes.rst:4744 msgid "" "Cast a memoryview to a new format or shape. *shape* defaults to " "``[byte_length//new_itemsize]``, which means that the result view will be " @@ -6718,7 +6867,7 @@ msgid "" "contiguous -> 1D." msgstr "" -#: ../../library/stdtypes.rst:4647 +#: ../../library/stdtypes.rst:4750 msgid "" "The destination format is restricted to a single element native format in :" "mod:`struct` syntax. One of the formats must be a byte format ('B', 'b' or " @@ -6726,11 +6875,11 @@ msgid "" "Note that all byte lengths may depend on the operating system." msgstr "" -#: ../../library/stdtypes.rst:4653 +#: ../../library/stdtypes.rst:4756 msgid "Cast 1D/long to 1D/unsigned bytes::" msgstr "" -#: ../../library/stdtypes.rst:4655 +#: ../../library/stdtypes.rst:4758 msgid "" ">>> import array\n" ">>> a = array.array('l', [1,2,3])\n" @@ -6774,11 +6923,11 @@ msgstr "" ">>> y.nbytes\n" "24" -#: ../../library/stdtypes.rst:4676 +#: ../../library/stdtypes.rst:4779 msgid "Cast 1D/unsigned bytes to 1D/char::" msgstr "" -#: ../../library/stdtypes.rst:4678 +#: ../../library/stdtypes.rst:4781 msgid "" ">>> b = bytearray(b'zyz')\n" ">>> x = memoryview(b)\n" @@ -6802,11 +6951,11 @@ msgstr "" ">>> b\n" "bytearray(b'ayz')" -#: ../../library/stdtypes.rst:4689 +#: ../../library/stdtypes.rst:4792 msgid "Cast 1D/bytes to 3D/ints to 1D/signed char::" msgstr "" -#: ../../library/stdtypes.rst:4691 +#: ../../library/stdtypes.rst:4794 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"i\"*12, *list(range(12)))\n" @@ -6856,11 +7005,11 @@ msgstr "" ">>> z.nbytes\n" "48" -#: ../../library/stdtypes.rst:4715 +#: ../../library/stdtypes.rst:4818 msgid "Cast 1D/unsigned long to 2D/unsigned long::" msgstr "" -#: ../../library/stdtypes.rst:4717 +#: ../../library/stdtypes.rst:4820 msgid "" ">>> buf = struct.pack(\"L\"*6, *list(range(6)))\n" ">>> x = memoryview(buf)\n" @@ -6882,33 +7031,33 @@ msgstr "" ">>> y.tolist()\n" "[[0, 1, 2], [3, 4, 5]]" -#: ../../library/stdtypes.rst:4729 +#: ../../library/stdtypes.rst:4832 msgid "The source format is no longer restricted when casting to a byte view." msgstr "" -#: ../../library/stdtypes.rst:4734 +#: ../../library/stdtypes.rst:4837 msgid "Count the number of occurrences of *value*." msgstr "計算 *value* 的出現次數" -#: ../../library/stdtypes.rst:4740 +#: ../../library/stdtypes.rst:4843 msgid "" "Return the index of the first occurrence of *value* (at or after index " "*start* and before index *stop*)." msgstr "" -#: ../../library/stdtypes.rst:4743 +#: ../../library/stdtypes.rst:4846 msgid "Raises a :exc:`ValueError` if *value* cannot be found." msgstr "在找不到 *value* 時引發 :exc:`ValueError`。" -#: ../../library/stdtypes.rst:4747 +#: ../../library/stdtypes.rst:4850 msgid "There are also several readonly attributes available:" msgstr "" -#: ../../library/stdtypes.rst:4751 +#: ../../library/stdtypes.rst:4854 msgid "The underlying object of the memoryview::" msgstr "memoryview 的底層物件: ::" -#: ../../library/stdtypes.rst:4753 +#: ../../library/stdtypes.rst:4856 msgid "" ">>> b = bytearray(b'xyz')\n" ">>> m = memoryview(b)\n" @@ -6920,14 +7069,14 @@ msgstr "" ">>> m.obj is b\n" "True" -#: ../../library/stdtypes.rst:4762 +#: ../../library/stdtypes.rst:4865 msgid "" "``nbytes == product(shape) * itemsize == len(m.tobytes())``. This is the " "amount of space in bytes that the array would use in a contiguous " "representation. It is not necessarily equal to ``len(m)``::" msgstr "" -#: ../../library/stdtypes.rst:4766 +#: ../../library/stdtypes.rst:4869 msgid "" ">>> import array\n" ">>> a = array.array('i', [1,2,3,4,5])\n" @@ -6959,11 +7108,11 @@ msgstr "" ">>> len(y.tobytes())\n" "12" -#: ../../library/stdtypes.rst:4781 +#: ../../library/stdtypes.rst:4884 msgid "Multi-dimensional arrays::" msgstr "" -#: ../../library/stdtypes.rst:4783 +#: ../../library/stdtypes.rst:4886 msgid "" ">>> import struct\n" ">>> buf = struct.pack(\"d\"*12, *[1.5*x for x in range(12)])\n" @@ -6987,11 +7136,11 @@ msgstr "" ">>> y.nbytes\n" "96" -#: ../../library/stdtypes.rst:4798 +#: ../../library/stdtypes.rst:4901 msgid "A bool indicating whether the memory is read only." msgstr "" -#: ../../library/stdtypes.rst:4802 +#: ../../library/stdtypes.rst:4905 msgid "" "A string containing the format (in :mod:`struct` module style) for each " "element in the view. A memoryview can be created from exporters with " @@ -6999,17 +7148,17 @@ msgid "" "restricted to native single element formats." msgstr "" -#: ../../library/stdtypes.rst:4807 +#: ../../library/stdtypes.rst:4910 msgid "" "format ``'B'`` is now handled according to the struct module syntax. This " "means that ``memoryview(b'abc')[0] == b'abc'[0] == 97``." msgstr "" -#: ../../library/stdtypes.rst:4813 +#: ../../library/stdtypes.rst:4916 msgid "The size in bytes of each element of the memoryview::" msgstr "" -#: ../../library/stdtypes.rst:4815 +#: ../../library/stdtypes.rst:4918 msgid "" ">>> import array, struct\n" ">>> m = memoryview(array.array('H', [32000, 32001, 32002]))\n" @@ -7029,49 +7178,49 @@ msgstr "" ">>> struct.calcsize('H') == m.itemsize\n" "True" -#: ../../library/stdtypes.rst:4826 +#: ../../library/stdtypes.rst:4929 msgid "" "An integer indicating how many dimensions of a multi-dimensional array the " "memory represents." msgstr "" -#: ../../library/stdtypes.rst:4831 +#: ../../library/stdtypes.rst:4934 msgid "" "A tuple of integers the length of :attr:`ndim` giving the shape of the " "memory as an N-dimensional array." msgstr "" -#: ../../library/stdtypes.rst:4834 ../../library/stdtypes.rst:4842 +#: ../../library/stdtypes.rst:4937 ../../library/stdtypes.rst:4945 msgid "An empty tuple instead of ``None`` when ndim = 0." msgstr "" -#: ../../library/stdtypes.rst:4839 +#: ../../library/stdtypes.rst:4942 msgid "" "A tuple of integers the length of :attr:`ndim` giving the size in bytes to " "access each element for each dimension of the array." msgstr "" -#: ../../library/stdtypes.rst:4847 +#: ../../library/stdtypes.rst:4950 msgid "Used internally for PIL-style arrays. The value is informational only." msgstr "" -#: ../../library/stdtypes.rst:4851 +#: ../../library/stdtypes.rst:4954 msgid "A bool indicating whether the memory is C-:term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4857 +#: ../../library/stdtypes.rst:4960 msgid "A bool indicating whether the memory is Fortran :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4863 +#: ../../library/stdtypes.rst:4966 msgid "A bool indicating whether the memory is :term:`contiguous`." msgstr "" -#: ../../library/stdtypes.rst:4871 +#: ../../library/stdtypes.rst:4974 msgid "Set Types --- :class:`set`, :class:`frozenset`" msgstr "" -#: ../../library/stdtypes.rst:4875 +#: ../../library/stdtypes.rst:4978 msgid "" "A :dfn:`set` object is an unordered collection of distinct :term:`hashable` " "objects. Common uses include membership testing, removing duplicates from a " @@ -7081,7 +7230,7 @@ msgid "" "`collections` module.)" msgstr "" -#: ../../library/stdtypes.rst:4882 +#: ../../library/stdtypes.rst:4985 msgid "" "Like other collections, sets support ``x in set``, ``len(set)``, and ``for x " "in set``. Being an unordered collection, sets do not record element " @@ -7089,7 +7238,7 @@ msgid "" "slicing, or other sequence-like behavior." msgstr "" -#: ../../library/stdtypes.rst:4887 +#: ../../library/stdtypes.rst:4990 msgid "" "There are currently two built-in set types, :class:`set` and :class:" "`frozenset`. The :class:`set` type is mutable --- the contents can be " @@ -7101,18 +7250,18 @@ msgid "" "of another set." msgstr "" -#: ../../library/stdtypes.rst:4896 +#: ../../library/stdtypes.rst:4999 msgid "" "Non-empty sets (not frozensets) can be created by placing a comma-separated " "list of elements within braces, for example: ``{'jack', 'sjoerd'}``, in " "addition to the :class:`set` constructor." msgstr "" -#: ../../library/stdtypes.rst:4900 +#: ../../library/stdtypes.rst:5003 msgid "The constructors for both classes work the same:" msgstr "" -#: ../../library/stdtypes.rst:4905 +#: ../../library/stdtypes.rst:5008 msgid "" "Return a new set or frozenset object whose elements are taken from " "*iterable*. The elements of a set must be :term:`hashable`. To represent " @@ -7120,92 +7269,92 @@ msgid "" "*iterable* is not specified, a new empty set is returned." msgstr "" -#: ../../library/stdtypes.rst:4911 +#: ../../library/stdtypes.rst:5014 msgid "Sets can be created by several means:" msgstr "集合可以以多種方式建立:" -#: ../../library/stdtypes.rst:4913 +#: ../../library/stdtypes.rst:5016 msgid "" "Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:4914 +#: ../../library/stdtypes.rst:5017 msgid "" "Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}``" msgstr "" -#: ../../library/stdtypes.rst:4915 +#: ../../library/stdtypes.rst:5018 msgid "" "Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', " "'foo'])``" msgstr "" -#: ../../library/stdtypes.rst:4917 +#: ../../library/stdtypes.rst:5020 msgid "" "Instances of :class:`set` and :class:`frozenset` provide the following " "operations:" msgstr "" -#: ../../library/stdtypes.rst:4922 +#: ../../library/stdtypes.rst:5025 msgid "Return the number of elements in set *s* (cardinality of *s*)." msgstr "" -#: ../../library/stdtypes.rst:4926 +#: ../../library/stdtypes.rst:5029 msgid "Test *x* for membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:4930 +#: ../../library/stdtypes.rst:5033 msgid "Test *x* for non-membership in *s*." msgstr "" -#: ../../library/stdtypes.rst:4935 +#: ../../library/stdtypes.rst:5038 msgid "" "Return ``True`` if the set has no elements in common with *other*. Sets are " "disjoint if and only if their intersection is the empty set." msgstr "" -#: ../../library/stdtypes.rst:4942 +#: ../../library/stdtypes.rst:5045 msgid "Test whether every element in the set is in *other*." msgstr "" -#: ../../library/stdtypes.rst:4946 +#: ../../library/stdtypes.rst:5049 msgid "" "Test whether the set is a proper subset of *other*, that is, ``set <= other " "and set != other``." msgstr "" -#: ../../library/stdtypes.rst:4953 +#: ../../library/stdtypes.rst:5056 msgid "Test whether every element in *other* is in the set." msgstr "" -#: ../../library/stdtypes.rst:4957 +#: ../../library/stdtypes.rst:5060 msgid "" "Test whether the set is a proper superset of *other*, that is, ``set >= " "other and set != other``." msgstr "" -#: ../../library/stdtypes.rst:4964 +#: ../../library/stdtypes.rst:5067 msgid "Return a new set with elements from the set and all others." msgstr "" -#: ../../library/stdtypes.rst:4970 +#: ../../library/stdtypes.rst:5073 msgid "Return a new set with elements common to the set and all others." msgstr "" -#: ../../library/stdtypes.rst:4976 +#: ../../library/stdtypes.rst:5079 msgid "Return a new set with elements in the set that are not in the others." msgstr "" -#: ../../library/stdtypes.rst:4982 +#: ../../library/stdtypes.rst:5085 msgid "" "Return a new set with elements in either the set or *other* but not both." msgstr "" -#: ../../library/stdtypes.rst:4987 +#: ../../library/stdtypes.rst:5090 msgid "Return a shallow copy of the set." msgstr "" -#: ../../library/stdtypes.rst:4990 +#: ../../library/stdtypes.rst:5093 msgid "" "Note, the non-operator versions of :meth:`~frozenset.union`, :meth:" "`~frozenset.intersection`, :meth:`~frozenset.difference`, :meth:`~frozenset." @@ -7216,7 +7365,7 @@ msgid "" "the more readable ``set('abc').intersection('cbs')``." msgstr "" -#: ../../library/stdtypes.rst:4997 +#: ../../library/stdtypes.rst:5100 msgid "" "Both :class:`set` and :class:`frozenset` support set to set comparisons. Two " "sets are equal if and only if every element of each set is contained in the " @@ -7226,14 +7375,14 @@ msgid "" "set is a proper superset of the second set (is a superset, but is not equal)." msgstr "" -#: ../../library/stdtypes.rst:5004 +#: ../../library/stdtypes.rst:5107 msgid "" "Instances of :class:`set` are compared to instances of :class:`frozenset` " "based on their members. For example, ``set('abc') == frozenset('abc')`` " "returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``." msgstr "" -#: ../../library/stdtypes.rst:5008 +#: ../../library/stdtypes.rst:5111 msgid "" "The subset and equality comparisons do not generalize to a total ordering " "function. For example, any two nonempty disjoint sets are not equal and are " @@ -7241,78 +7390,78 @@ msgid "" "``ab``." msgstr "" -#: ../../library/stdtypes.rst:5013 +#: ../../library/stdtypes.rst:5116 msgid "" "Since sets only define partial ordering (subset relationships), the output " "of the :meth:`list.sort` method is undefined for lists of sets." msgstr "" -#: ../../library/stdtypes.rst:5016 +#: ../../library/stdtypes.rst:5119 msgid "Set elements, like dictionary keys, must be :term:`hashable`." msgstr "" -#: ../../library/stdtypes.rst:5018 +#: ../../library/stdtypes.rst:5121 msgid "" "Binary operations that mix :class:`set` instances with :class:`frozenset` " "return the type of the first operand. For example: ``frozenset('ab') | " "set('bc')`` returns an instance of :class:`frozenset`." msgstr "" -#: ../../library/stdtypes.rst:5022 +#: ../../library/stdtypes.rst:5125 msgid "" "The following table lists operations available for :class:`set` that do not " "apply to immutable instances of :class:`frozenset`:" msgstr "" -#: ../../library/stdtypes.rst:5028 +#: ../../library/stdtypes.rst:5131 msgid "Update the set, adding elements from all others." msgstr "" -#: ../../library/stdtypes.rst:5033 +#: ../../library/stdtypes.rst:5136 msgid "Update the set, keeping only elements found in it and all others." msgstr "" -#: ../../library/stdtypes.rst:5038 +#: ../../library/stdtypes.rst:5141 msgid "Update the set, removing elements found in others." msgstr "" -#: ../../library/stdtypes.rst:5043 +#: ../../library/stdtypes.rst:5146 msgid "" "Update the set, keeping only elements found in either set, but not in both." msgstr "" -#: ../../library/stdtypes.rst:5047 +#: ../../library/stdtypes.rst:5150 msgid "Add element *elem* to the set." msgstr "將元素 *elem* 加入集合。" -#: ../../library/stdtypes.rst:5051 +#: ../../library/stdtypes.rst:5154 msgid "" "Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is not " "contained in the set." msgstr "" -#: ../../library/stdtypes.rst:5056 +#: ../../library/stdtypes.rst:5159 msgid "Remove element *elem* from the set if it is present." msgstr "如果 *elem* 存在於集合中則將其移除。" -#: ../../library/stdtypes.rst:5060 +#: ../../library/stdtypes.rst:5163 msgid "" "Remove and return an arbitrary element from the set. Raises :exc:`KeyError` " "if the set is empty." msgstr "" -#: ../../library/stdtypes.rst:5065 +#: ../../library/stdtypes.rst:5168 msgid "Remove all elements from the set." msgstr "從集合中移除所有元素。" -#: ../../library/stdtypes.rst:5068 +#: ../../library/stdtypes.rst:5171 msgid "" "Note, the non-operator versions of the :meth:`~set.update`, :meth:`~set." "intersection_update`, :meth:`~set.difference_update`, and :meth:`~set." "symmetric_difference_update` methods will accept any iterable as an argument." msgstr "" -#: ../../library/stdtypes.rst:5073 +#: ../../library/stdtypes.rst:5176 msgid "" "Note, the *elem* argument to the :meth:`~object.__contains__`, :meth:`~set." "remove`, and :meth:`~set.discard` methods may be a set. To support " @@ -7320,11 +7469,11 @@ msgid "" "*elem*." msgstr "" -#: ../../library/stdtypes.rst:5082 +#: ../../library/stdtypes.rst:5185 msgid "Mapping Types --- :class:`dict`" msgstr "" -#: ../../library/stdtypes.rst:5092 +#: ../../library/stdtypes.rst:5195 msgid "" "A :term:`mapping` object maps :term:`hashable` values to arbitrary objects. " "Mappings are mutable objects. There is currently only one standard mapping " @@ -7333,7 +7482,7 @@ msgid "" "module.)" msgstr "" -#: ../../library/stdtypes.rst:5098 +#: ../../library/stdtypes.rst:5201 msgid "" "A dictionary's keys are *almost* arbitrary values. Values that are not :" "term:`hashable`, that is, values containing lists, dictionaries or other " @@ -7342,33 +7491,33 @@ msgid "" "and ``True``) can be used interchangeably to index the same dictionary entry." msgstr "" -#: ../../library/stdtypes.rst:5109 +#: ../../library/stdtypes.rst:5212 msgid "" "Return a new dictionary initialized from an optional positional argument and " "a possibly empty set of keyword arguments." msgstr "" -#: ../../library/stdtypes.rst:5112 +#: ../../library/stdtypes.rst:5215 msgid "Dictionaries can be created by several means:" msgstr "字典可以用數種方式建立:" -#: ../../library/stdtypes.rst:5114 +#: ../../library/stdtypes.rst:5217 msgid "" "Use a comma-separated list of ``key: value`` pairs within braces: ``{'jack': " "4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``" msgstr "" -#: ../../library/stdtypes.rst:5116 +#: ../../library/stdtypes.rst:5219 msgid "Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``" msgstr "" -#: ../../library/stdtypes.rst:5117 +#: ../../library/stdtypes.rst:5220 msgid "" "Use the type constructor: ``dict()``, ``dict([('foo', 100), ('bar', " "200)])``, ``dict(foo=100, bar=200)``" msgstr "" -#: ../../library/stdtypes.rst:5120 +#: ../../library/stdtypes.rst:5223 msgid "" "If no positional argument is given, an empty dictionary is created. If a " "positional argument is given and it defines a ``keys()`` method, a " @@ -7381,7 +7530,7 @@ msgid "" "that key becomes the corresponding value in the new dictionary." msgstr "" -#: ../../library/stdtypes.rst:5130 +#: ../../library/stdtypes.rst:5233 msgid "" "If keyword arguments are given, the keyword arguments and their values are " "added to the dictionary created from the positional argument. If a key " @@ -7389,7 +7538,7 @@ msgid "" "the value from the positional argument." msgstr "" -#: ../../library/stdtypes.rst:5135 +#: ../../library/stdtypes.rst:5238 msgid "" "Dictionaries compare equal if and only if they have the same ``(key, " "value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', " @@ -7398,7 +7547,7 @@ msgid "" "``{\"one\": 1, \"two\": 2, \"three\": 3}``::" msgstr "" -#: ../../library/stdtypes.rst:5141 +#: ../../library/stdtypes.rst:5244 msgid "" ">>> a = dict(one=1, two=2, three=3)\n" ">>> b = {'one': 1, 'two': 2, 'three': 3}\n" @@ -7418,19 +7567,19 @@ msgstr "" ">>> a == b == c == d == e == f\n" "True" -#: ../../library/stdtypes.rst:5150 +#: ../../library/stdtypes.rst:5253 msgid "" "Providing keyword arguments as in the first example only works for keys that " "are valid Python identifiers. Otherwise, any valid keys can be used." msgstr "" -#: ../../library/stdtypes.rst:5153 +#: ../../library/stdtypes.rst:5256 msgid "" "Dictionaries preserve insertion order. Note that updating a key does not " "affect the order. Keys added after deletion are inserted at the end. ::" msgstr "" -#: ../../library/stdtypes.rst:5156 +#: ../../library/stdtypes.rst:5259 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -7462,33 +7611,33 @@ msgstr "" ">>> d\n" "{'one': 42, 'three': 3, 'four': 4, 'two': None}" -#: ../../library/stdtypes.rst:5171 +#: ../../library/stdtypes.rst:5274 msgid "" "Dictionary order is guaranteed to be insertion order. This behavior was an " "implementation detail of CPython from 3.6." msgstr "" -#: ../../library/stdtypes.rst:5175 +#: ../../library/stdtypes.rst:5278 msgid "" "These are the operations that dictionaries support (and therefore, custom " "mapping types should support too):" msgstr "" -#: ../../library/stdtypes.rst:5180 +#: ../../library/stdtypes.rst:5283 msgid "Return a list of all the keys used in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:5184 +#: ../../library/stdtypes.rst:5287 msgid "Return the number of items in the dictionary *d*." msgstr "" -#: ../../library/stdtypes.rst:5188 +#: ../../library/stdtypes.rst:5291 msgid "" "Return the item of *d* with key *key*. Raises a :exc:`KeyError` if *key* is " "not in the map." msgstr "" -#: ../../library/stdtypes.rst:5193 +#: ../../library/stdtypes.rst:5296 msgid "" "If a subclass of dict defines a method :meth:`~object.__missing__` and *key* " "is not present, the ``d[key]`` operation calls that method with the key " @@ -7499,7 +7648,7 @@ msgid "" "__missing__` must be a method; it cannot be an instance variable::" msgstr "" -#: ../../library/stdtypes.rst:5201 +#: ../../library/stdtypes.rst:5304 msgid "" ">>> class Counter(dict):\n" "... def __missing__(self, key):\n" @@ -7523,51 +7672,51 @@ msgstr "" ">>> c['red']\n" "1" -#: ../../library/stdtypes.rst:5212 +#: ../../library/stdtypes.rst:5315 msgid "" "The example above shows part of the implementation of :class:`collections." "Counter`. A different :meth:`!__missing__` method is used by :class:" "`collections.defaultdict`." msgstr "" -#: ../../library/stdtypes.rst:5219 +#: ../../library/stdtypes.rst:5322 msgid "Set ``d[key]`` to *value*." msgstr "將 ``d[key]`` 設為 *value*。" -#: ../../library/stdtypes.rst:5223 +#: ../../library/stdtypes.rst:5326 msgid "" "Remove ``d[key]`` from *d*. Raises a :exc:`KeyError` if *key* is not in the " "map." msgstr "從 *d* 中移除 ``d[key]``。若 *key* 不在對映中則引發 :exc:`KeyError`。" -#: ../../library/stdtypes.rst:5228 +#: ../../library/stdtypes.rst:5331 msgid "Return ``True`` if *d* has a key *key*, else ``False``." msgstr "若 *d* 有鍵 *key* 則回傳 ``True``,否則回傳 ``False``。" -#: ../../library/stdtypes.rst:5232 +#: ../../library/stdtypes.rst:5335 msgid "Equivalent to ``not key in d``." msgstr "等價於 ``not key in d``。" -#: ../../library/stdtypes.rst:5236 +#: ../../library/stdtypes.rst:5339 msgid "" "Return an iterator over the keys of the dictionary. This is a shortcut for " "``iter(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:5241 +#: ../../library/stdtypes.rst:5344 msgid "Remove all items from the dictionary." msgstr "從字典中移除所有項目。" -#: ../../library/stdtypes.rst:5245 +#: ../../library/stdtypes.rst:5348 msgid "Return a shallow copy of the dictionary." msgstr "" -#: ../../library/stdtypes.rst:5249 +#: ../../library/stdtypes.rst:5352 msgid "" "Create a new dictionary with keys from *iterable* and values set to *value*." msgstr "" -#: ../../library/stdtypes.rst:5251 +#: ../../library/stdtypes.rst:5354 msgid "" ":meth:`fromkeys` is a class method that returns a new dictionary. *value* " "defaults to ``None``. All of the values refer to just a single instance, so " @@ -7576,70 +7725,70 @@ msgid "" "` instead." msgstr "" -#: ../../library/stdtypes.rst:5259 +#: ../../library/stdtypes.rst:5362 msgid "" "Return the value for *key* if *key* is in the dictionary, else *default*. If " "*default* is not given, it defaults to ``None``, so that this method never " "raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:5265 +#: ../../library/stdtypes.rst:5368 msgid "" "Return a new view of the dictionary's items (``(key, value)`` pairs). See " "the :ref:`documentation of view objects `." msgstr "" -#: ../../library/stdtypes.rst:5270 +#: ../../library/stdtypes.rst:5373 msgid "" "Return a new view of the dictionary's keys. See the :ref:`documentation of " "view objects `." msgstr "" -#: ../../library/stdtypes.rst:5276 +#: ../../library/stdtypes.rst:5379 msgid "" "If *key* is in the dictionary, remove it and return its value, else return " "*default*. If *default* is not given and *key* is not in the dictionary, a :" "exc:`KeyError` is raised." msgstr "" -#: ../../library/stdtypes.rst:5282 +#: ../../library/stdtypes.rst:5385 msgid "" "Remove and return a ``(key, value)`` pair from the dictionary. Pairs are " "returned in :abbr:`LIFO (last-in, first-out)` order." msgstr "" -#: ../../library/stdtypes.rst:5285 +#: ../../library/stdtypes.rst:5388 msgid "" ":meth:`popitem` is useful to destructively iterate over a dictionary, as " "often used in set algorithms. If the dictionary is empty, calling :meth:" "`popitem` raises a :exc:`KeyError`." msgstr "" -#: ../../library/stdtypes.rst:5289 +#: ../../library/stdtypes.rst:5392 msgid "" "LIFO order is now guaranteed. In prior versions, :meth:`popitem` would " "return an arbitrary key/value pair." msgstr "" -#: ../../library/stdtypes.rst:5295 +#: ../../library/stdtypes.rst:5398 msgid "" "Return a reverse iterator over the keys of the dictionary. This is a " "shortcut for ``reversed(d.keys())``." msgstr "" -#: ../../library/stdtypes.rst:5302 +#: ../../library/stdtypes.rst:5405 msgid "" "If *key* is in the dictionary, return its value. If not, insert *key* with " "a value of *default* and return *default*. *default* defaults to ``None``." msgstr "" -#: ../../library/stdtypes.rst:5310 +#: ../../library/stdtypes.rst:5413 msgid "" "Update the dictionary with the key/value pairs from *mapping* or *iterable* " "and *kwargs*, overwriting existing keys. Return ``None``." msgstr "" -#: ../../library/stdtypes.rst:5313 +#: ../../library/stdtypes.rst:5416 msgid "" ":meth:`update` accepts either another object with a ``keys()`` method (in " "which case :meth:`~object.__getitem__` is called with every key returned " @@ -7648,20 +7797,20 @@ msgid "" "is then updated with those key/value pairs: ``d.update(red=1, blue=2)``." msgstr "" -#: ../../library/stdtypes.rst:5321 +#: ../../library/stdtypes.rst:5424 msgid "" "Return a new view of the dictionary's values. See the :ref:`documentation " "of view objects `." msgstr "" -#: ../../library/stdtypes.rst:5324 +#: ../../library/stdtypes.rst:5427 msgid "" "An equality comparison between one ``dict.values()`` view and another will " "always return ``False``. This also applies when comparing ``dict.values()`` " "to itself::" msgstr "" -#: ../../library/stdtypes.rst:5328 +#: ../../library/stdtypes.rst:5431 msgid "" ">>> d = {'a': 1}\n" ">>> d.values() == d.values()\n" @@ -7671,25 +7820,25 @@ msgstr "" ">>> d.values() == d.values()\n" "False" -#: ../../library/stdtypes.rst:5334 +#: ../../library/stdtypes.rst:5437 msgid "" "Create a new dictionary with the merged keys and values of *d* and *other*, " "which must both be dictionaries. The values of *other* take priority when " "*d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:5342 +#: ../../library/stdtypes.rst:5445 msgid "" "Update the dictionary *d* with keys and values from *other*, which may be " "either a :term:`mapping` or an :term:`iterable` of key/value pairs. The " "values of *other* take priority when *d* and *other* share keys." msgstr "" -#: ../../library/stdtypes.rst:5348 +#: ../../library/stdtypes.rst:5451 msgid "Dictionaries and dictionary views are reversible. ::" msgstr "" -#: ../../library/stdtypes.rst:5350 +#: ../../library/stdtypes.rst:5453 msgid "" ">>> d = {\"one\": 1, \"two\": 2, \"three\": 3, \"four\": 4}\n" ">>> d\n" @@ -7711,21 +7860,21 @@ msgstr "" ">>> list(reversed(d.items()))\n" "[('four', 4), ('three', 3), ('two', 2), ('one', 1)]" -#: ../../library/stdtypes.rst:5360 +#: ../../library/stdtypes.rst:5463 msgid "Dictionaries are now reversible." msgstr "" -#: ../../library/stdtypes.rst:5365 +#: ../../library/stdtypes.rst:5468 msgid "" ":class:`types.MappingProxyType` can be used to create a read-only view of a :" "class:`dict`." msgstr "" -#: ../../library/stdtypes.rst:5372 +#: ../../library/stdtypes.rst:5475 msgid "Dictionary view objects" msgstr "字典視圖物件" -#: ../../library/stdtypes.rst:5374 +#: ../../library/stdtypes.rst:5477 msgid "" "The objects returned by :meth:`dict.keys`, :meth:`dict.values` and :meth:" "`dict.items` are *view objects*. They provide a dynamic view on the " @@ -7733,23 +7882,23 @@ msgid "" "reflects these changes." msgstr "" -#: ../../library/stdtypes.rst:5379 +#: ../../library/stdtypes.rst:5482 msgid "" "Dictionary views can be iterated over to yield their respective data, and " "support membership tests:" msgstr "" -#: ../../library/stdtypes.rst:5384 +#: ../../library/stdtypes.rst:5487 msgid "Return the number of entries in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:5388 +#: ../../library/stdtypes.rst:5491 msgid "" "Return an iterator over the keys, values or items (represented as tuples of " "``(key, value)``) in the dictionary." msgstr "" -#: ../../library/stdtypes.rst:5391 +#: ../../library/stdtypes.rst:5494 msgid "" "Keys and values are iterated over in insertion order. This allows the " "creation of ``(value, key)`` pairs using :func:`zip`: ``pairs = zip(d." @@ -7757,39 +7906,39 @@ msgid "" "[(v, k) for (k, v) in d.items()]``." msgstr "" -#: ../../library/stdtypes.rst:5396 +#: ../../library/stdtypes.rst:5499 msgid "" "Iterating views while adding or deleting entries in the dictionary may raise " "a :exc:`RuntimeError` or fail to iterate over all entries." msgstr "" -#: ../../library/stdtypes.rst:5399 +#: ../../library/stdtypes.rst:5502 msgid "Dictionary order is guaranteed to be insertion order." msgstr "" -#: ../../library/stdtypes.rst:5404 +#: ../../library/stdtypes.rst:5507 msgid "" "Return ``True`` if *x* is in the underlying dictionary's keys, values or " "items (in the latter case, *x* should be a ``(key, value)`` tuple)." msgstr "" -#: ../../library/stdtypes.rst:5409 +#: ../../library/stdtypes.rst:5512 msgid "" "Return a reverse iterator over the keys, values or items of the dictionary. " "The view will be iterated in reverse order of the insertion." msgstr "" -#: ../../library/stdtypes.rst:5412 +#: ../../library/stdtypes.rst:5515 msgid "Dictionary views are now reversible." msgstr "" -#: ../../library/stdtypes.rst:5417 +#: ../../library/stdtypes.rst:5520 msgid "" "Return a :class:`types.MappingProxyType` that wraps the original dictionary " "to which the view refers." msgstr "" -#: ../../library/stdtypes.rst:5422 +#: ../../library/stdtypes.rst:5525 msgid "" "Keys views are set-like since their entries are unique and :term:`hashable`. " "Items views also have set-like operations since the (key, value) pairs are " @@ -7803,11 +7952,11 @@ msgid "" "input." msgstr "" -#: ../../library/stdtypes.rst:5434 +#: ../../library/stdtypes.rst:5537 msgid "An example of dictionary view usage::" msgstr "" -#: ../../library/stdtypes.rst:5436 +#: ../../library/stdtypes.rst:5539 msgid "" ">>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}\n" ">>> keys = dishes.keys()\n" @@ -7848,11 +7997,11 @@ msgid "" "500" msgstr "" -#: ../../library/stdtypes.rst:5478 +#: ../../library/stdtypes.rst:5581 msgid "Context Manager Types" msgstr "情境管理器型別" -#: ../../library/stdtypes.rst:5485 +#: ../../library/stdtypes.rst:5588 msgid "" "Python's :keyword:`with` statement supports the concept of a runtime context " "defined by a context manager. This is implemented using a pair of methods " @@ -7863,7 +8012,7 @@ msgstr "" "要使用兩個方法來實作,該方法讓使用者定義類別能夠去定義 runtime 情境,且該情境" "在執行陳述式主體 (statement body) 之前進入、在陳述式結束時退出:" -#: ../../library/stdtypes.rst:5493 +#: ../../library/stdtypes.rst:5596 msgid "" "Enter the runtime context and return either this object or another object " "related to the runtime context. The value returned by this method is bound " @@ -7874,7 +8023,7 @@ msgstr "" "的值有被綁定到使用此情境管理器的 :keyword:`with` 陳述式的 :keyword:`!as` 子句" "中的識別字。" -#: ../../library/stdtypes.rst:5498 +#: ../../library/stdtypes.rst:5601 msgid "" "An example of a context manager that returns itself is a :term:`file " "object`. File objects return themselves from __enter__() to allow :func:" @@ -7883,7 +8032,7 @@ msgstr "" "一個會回傳自己的情境管理器範例是 :term:`file object`。檔案物件從 __enter__() " "回傳自己,以允許將 :func:`open` 用作 :keyword:`with` 陳述式中的情境運算式。" -#: ../../library/stdtypes.rst:5502 +#: ../../library/stdtypes.rst:5605 msgid "" "An example of a context manager that returns a related object is the one " "returned by :func:`decimal.localcontext`. These managers set the active " @@ -7897,7 +8046,7 @@ msgstr "" "本。這允許對 :keyword:`with` 陳述式主體中的目前十進位情境進行更改,而不會影" "響 :keyword:`!with` 陳述式外部的程式碼。" -#: ../../library/stdtypes.rst:5512 +#: ../../library/stdtypes.rst:5615 msgid "" "Exit the runtime context and return a Boolean flag indicating if any " "exception that occurred should be suppressed. If an exception occurred while " @@ -7909,7 +8058,7 @@ msgstr "" "keyword:`with` 陳述式主體時發生例外,則引數包含例外型別、值和回溯 " "(traceback) 資訊。否則,所有三個引數都是 ``None``。" -#: ../../library/stdtypes.rst:5517 +#: ../../library/stdtypes.rst:5620 msgid "" "Returning a true value from this method will cause the :keyword:`with` " "statement to suppress the exception and continue execution with the " @@ -7920,14 +8069,14 @@ msgstr "" "keyword:`!with` 陳述式之後的陳述式。否則,該例外將在該方法執行完畢後繼續傳播 " "(propagate)。" -#: ../../library/stdtypes.rst:5522 +#: ../../library/stdtypes.rst:5625 msgid "" "If this method raises an exception while handling an earlier exception from " "the :keyword:`with` block, the new exception is raised, and the original " "exception is stored in its :attr:`~BaseException.__context__` attribute." msgstr "" -#: ../../library/stdtypes.rst:5526 +#: ../../library/stdtypes.rst:5629 msgid "" "The exception passed in should never be reraised explicitly - instead, this " "method should return a false value to indicate that the method completed " @@ -7939,7 +8088,7 @@ msgstr "" "已成功完成且不希望抑制引發的例外。這讓情境管理程式碼能輕鬆檢測 :meth:" "`~object.__exit__` 方法是否曾實際失敗過。" -#: ../../library/stdtypes.rst:5532 +#: ../../library/stdtypes.rst:5635 msgid "" "Python defines several context managers to support easy thread " "synchronisation, prompt closure of files or other objects, and simpler " @@ -7951,7 +8100,7 @@ msgstr "" "及對有效十進位算術情境的更簡單操作。除了情境管理協定的實作之外,不會對特定型" "別進行特殊處理。更多範例請參閱 :mod:`contextlib` 模組。" -#: ../../library/stdtypes.rst:5538 +#: ../../library/stdtypes.rst:5641 msgid "" "Python's :term:`generator`\\s and the :class:`contextlib.contextmanager` " "decorator provide a convenient way to implement these protocols. If a " @@ -7966,7 +8115,7 @@ msgstr "" "`~contextmanager.__enter__` 和 :meth:`~contextmanager.__exit__` 方法的情境管" "理器,而不是由未裝飾產生器函式產生的疊代器。" -#: ../../library/stdtypes.rst:5545 +#: ../../library/stdtypes.rst:5648 msgid "" "Note that there is no specific slot for any of these methods in the type " "structure for Python objects in the Python/C API. Extension types wanting to " @@ -7978,7 +8127,7 @@ msgstr "" "定義這些方法的擴充型別必須將它們作為普通的 Python 可存取方法提供。與設定 " "runtime 情境的開銷相比,單一類別字典查找的開銷可以忽略不計。" -#: ../../library/stdtypes.rst:5553 +#: ../../library/stdtypes.rst:5656 msgid "" "Type Annotation Types --- :ref:`Generic Alias `, :ref:" "`Union `" @@ -7986,7 +8135,7 @@ msgstr "" "型別註釋的型別 --- :ref:`泛型別名 (Generic Alias) `、:" "ref:`聯合 (Union) `" -#: ../../library/stdtypes.rst:5558 +#: ../../library/stdtypes.rst:5661 msgid "" "The core built-in types for :term:`type annotations ` are :ref:" "`Generic Alias ` and :ref:`Union `." @@ -7994,11 +8143,11 @@ msgstr "" ":term:`型別註釋 ` 的核心內建型別是\\ :ref:`泛型別名 `\\ 和\\ :ref:`聯合 `。" -#: ../../library/stdtypes.rst:5565 +#: ../../library/stdtypes.rst:5668 msgid "Generic Alias Type" msgstr "泛型別名型別" -#: ../../library/stdtypes.rst:5571 +#: ../../library/stdtypes.rst:5674 msgid "" "``GenericAlias`` objects are generally created by :ref:`subscripting " "` a class. They are most often used with :ref:`container " @@ -8014,7 +8163,7 @@ msgstr "" "立的。``GenericAlias`` 物件主要會與\\ :term:`型別註釋 ` 一起使" "用。" -#: ../../library/stdtypes.rst:5581 +#: ../../library/stdtypes.rst:5684 msgid "" "It is generally only possible to subscript a class if the class implements " "the special method :meth:`~object.__class_getitem__`." @@ -8022,7 +8171,7 @@ msgstr "" "通常只有當類別有實作特殊方法 :meth:`~object.__class_getitem__` 時才可以去下標" "該類別。" -#: ../../library/stdtypes.rst:5584 +#: ../../library/stdtypes.rst:5687 msgid "" "A ``GenericAlias`` object acts as a proxy for a :term:`generic type`, " "implementing *parameterized generics*." @@ -8030,7 +8179,7 @@ msgstr "" "將一個 ``GenericAlias`` 物件用作 :term:`generic type` 的代理,實作\\ *參數化" "泛型 (parameterized generics)*。" -#: ../../library/stdtypes.rst:5587 +#: ../../library/stdtypes.rst:5690 msgid "" "For a container class, the argument(s) supplied to a :ref:`subscription " "` of the class may indicate the type(s) of the elements an " @@ -8042,7 +8191,7 @@ msgstr "" "物件所包含元素的型別。例如 ``set[bytes]`` 可以用於型別註釋來表示一個 :class:" "`set`,其中所有元素的型別都是 :class:`bytes`。" -#: ../../library/stdtypes.rst:5593 +#: ../../library/stdtypes.rst:5696 msgid "" "For a class which defines :meth:`~object.__class_getitem__` but is not a " "container, the argument(s) supplied to a subscription of the class will " @@ -8054,7 +8203,7 @@ msgstr "" "標引數通常會指示物件上有定義的一個或多個方法的回傳型別。例如\\ :mod:`正規表示" "式 `\\ 可以用於 :class:`str` 和 :class:`bytes` 資料型別:" -#: ../../library/stdtypes.rst:5599 +#: ../../library/stdtypes.rst:5702 msgid "" "If ``x = re.search('foo', 'foo')``, ``x`` will be a :ref:`re.Match ` object where the return values of ``x.group(0)`` and ``x[0]`` will " @@ -8066,7 +8215,7 @@ msgstr "" "別。我們就可以用 ``GenericAlias`` ``re.Match[str]`` 在型別註釋中表示這種物" "件。" -#: ../../library/stdtypes.rst:5605 +#: ../../library/stdtypes.rst:5708 msgid "" "If ``y = re.search(b'bar', b'bar')``, (note the ``b`` for :class:`bytes`), " "``y`` will also be an instance of ``re.Match``, but the return values of ``y." @@ -8079,7 +8228,7 @@ msgstr "" "別都是 :class:`bytes`。在型別註釋中,我們將用 ``re.Match[bytes]`` 來表示各" "種 :ref:`re.Match ` 物件。" -#: ../../library/stdtypes.rst:5611 +#: ../../library/stdtypes.rst:5714 msgid "" "``GenericAlias`` objects are instances of the class :class:`types." "GenericAlias`, which can also be used to create ``GenericAlias`` objects " @@ -8088,7 +8237,7 @@ msgstr "" "``GenericAlias`` 物件是 :class:`types.GenericAlias` 類別的實例,也可以用來直" "接建立 ``GenericAlias`` 物件。" -#: ../../library/stdtypes.rst:5617 +#: ../../library/stdtypes.rst:5720 msgid "" "Creates a ``GenericAlias`` representing a type ``T`` parameterized by types " "*X*, *Y*, and more depending on the ``T`` used. For example, a function " @@ -8098,7 +8247,7 @@ msgstr "" "所使用的 ``T``)來參數化。例如,一個函式需要一個包含 :class:`float` 元素的 :" "class:`list`: ::" -#: ../../library/stdtypes.rst:5622 +#: ../../library/stdtypes.rst:5725 msgid "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" @@ -8106,7 +8255,7 @@ msgstr "" "def average(values: list[float]) -> float:\n" " return sum(values) / len(values)" -#: ../../library/stdtypes.rst:5625 +#: ../../library/stdtypes.rst:5728 msgid "" "Another example for :term:`mapping` objects, using a :class:`dict`, which is " "a generic type expecting two type parameters representing the key type and " @@ -8117,7 +8266,7 @@ msgstr "" "別,需要兩個型別參數,分別表示鍵型別和值型別。在此範例中,函式需要一個 " "``dict``,其帶有 :class:`str` 型別的鍵和 :class:`int` 型別的值: ::" -#: ../../library/stdtypes.rst:5630 +#: ../../library/stdtypes.rst:5733 msgid "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." @@ -8125,7 +8274,7 @@ msgstr "" "def send_post_request(url: str, body: dict[str, int]) -> None:\n" " ..." -#: ../../library/stdtypes.rst:5633 +#: ../../library/stdtypes.rst:5736 msgid "" "The builtin functions :func:`isinstance` and :func:`issubclass` do not " "accept ``GenericAlias`` types for their second argument::" @@ -8133,7 +8282,7 @@ msgstr "" "內建函式 :func:`isinstance` 和 :func:`issubclass` 不接受 ``GenericAlias`` 型" "別作為第二個引數: ::" -#: ../../library/stdtypes.rst:5636 +#: ../../library/stdtypes.rst:5739 msgid "" ">>> isinstance([1, 2], list[str])\n" "Traceback (most recent call last):\n" @@ -8145,7 +8294,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: isinstance() argument 2 cannot be a parameterized generic" -#: ../../library/stdtypes.rst:5641 +#: ../../library/stdtypes.rst:5744 msgid "" "The Python runtime does not enforce :term:`type annotations `. " "This extends to generic types and their type parameters. When creating a " @@ -8157,7 +8306,7 @@ msgstr "" "及其型別參數。當從 ``GenericAlias`` 建立容器物件時,不會檢查容器中元素的型" "別。例如,不鼓勵使用以下程式碼,但 runtime 不會出現錯誤: ::" -#: ../../library/stdtypes.rst:5647 +#: ../../library/stdtypes.rst:5750 msgid "" ">>> t = list[str]\n" ">>> t([1, 2, 3])\n" @@ -8167,13 +8316,13 @@ msgstr "" ">>> t([1, 2, 3])\n" "[1, 2, 3]" -#: ../../library/stdtypes.rst:5651 +#: ../../library/stdtypes.rst:5754 msgid "" "Furthermore, parameterized generics erase type parameters during object " "creation::" msgstr "此外,參數化泛型在物件建立期間會擦除 (erase) 型別參數: ::" -#: ../../library/stdtypes.rst:5654 +#: ../../library/stdtypes.rst:5757 msgid "" ">>> t = list[str]\n" ">>> type(t)\n" @@ -8191,13 +8340,13 @@ msgstr "" ">>> type(l)\n" "" -#: ../../library/stdtypes.rst:5662 +#: ../../library/stdtypes.rst:5765 msgid "" "Calling :func:`repr` or :func:`str` on a generic shows the parameterized " "type::" msgstr "在泛型上呼叫 :func:`repr` 或 :func:`str` 會顯示參數化型別: ::" -#: ../../library/stdtypes.rst:5664 +#: ../../library/stdtypes.rst:5767 msgid "" ">>> repr(list[int])\n" "'list[int]'\n" @@ -8211,7 +8360,7 @@ msgstr "" ">>> str(list[int])\n" "'list[int]'" -#: ../../library/stdtypes.rst:5670 +#: ../../library/stdtypes.rst:5773 msgid "" "The :meth:`~object.__getitem__` method of generic containers will raise an " "exception to disallow mistakes like ``dict[str][str]``::" @@ -8219,7 +8368,7 @@ msgstr "" "為防止像是 ``dict[str][str]`` 的錯誤出現,泛型容器的 :meth:`~object." "__getitem__` 方法會在這種情況下引發例外: ::" -#: ../../library/stdtypes.rst:5673 +#: ../../library/stdtypes.rst:5776 msgid "" ">>> dict[str][str]\n" "Traceback (most recent call last):\n" @@ -8231,7 +8380,7 @@ msgstr "" " ...\n" "TypeError: dict[str] is not a generic class" -#: ../../library/stdtypes.rst:5678 +#: ../../library/stdtypes.rst:5781 msgid "" "However, such expressions are valid when :ref:`type variables ` " "are used. The index must have as many elements as there are type variable " @@ -8241,7 +8390,7 @@ msgstr "" "的。索引的元素數量必須與 ``GenericAlias`` 物件的 :attr:`~genericalias." "__args__` 中的型別變數項目一樣多: ::" -#: ../../library/stdtypes.rst:5682 +#: ../../library/stdtypes.rst:5785 msgid "" ">>> from typing import TypeVar\n" ">>> Y = TypeVar('Y')\n" @@ -8253,253 +8402,253 @@ msgstr "" ">>> dict[str, Y][int]\n" "dict[str, int]" -#: ../../library/stdtypes.rst:5689 +#: ../../library/stdtypes.rst:5792 msgid "Standard Generic Classes" msgstr "標準泛型類別" -#: ../../library/stdtypes.rst:5691 +#: ../../library/stdtypes.rst:5794 msgid "" "The following standard library classes support parameterized generics. This " "list is non-exhaustive." msgstr "以下標準函式庫類別有支援參數化泛型。此列表並非詳盡無遺。" -#: ../../library/stdtypes.rst:5694 +#: ../../library/stdtypes.rst:5797 msgid ":class:`tuple`" msgstr ":class:`tuple`" -#: ../../library/stdtypes.rst:5695 +#: ../../library/stdtypes.rst:5798 msgid ":class:`list`" msgstr ":class:`list`" -#: ../../library/stdtypes.rst:5696 +#: ../../library/stdtypes.rst:5799 msgid ":class:`dict`" msgstr ":class:`dict`" -#: ../../library/stdtypes.rst:5697 +#: ../../library/stdtypes.rst:5800 msgid ":class:`set`" msgstr ":class:`set`" -#: ../../library/stdtypes.rst:5698 +#: ../../library/stdtypes.rst:5801 msgid ":class:`frozenset`" msgstr ":class:`frozenset`" -#: ../../library/stdtypes.rst:5699 +#: ../../library/stdtypes.rst:5802 msgid ":class:`type`" msgstr ":class:`type`" -#: ../../library/stdtypes.rst:5700 +#: ../../library/stdtypes.rst:5803 msgid ":class:`asyncio.Future`" msgstr ":class:`asyncio.Future`" -#: ../../library/stdtypes.rst:5701 +#: ../../library/stdtypes.rst:5804 msgid ":class:`asyncio.Task`" msgstr ":class:`asyncio.Task`" -#: ../../library/stdtypes.rst:5702 +#: ../../library/stdtypes.rst:5805 msgid ":class:`collections.deque`" msgstr ":class:`collections.deque`" -#: ../../library/stdtypes.rst:5703 +#: ../../library/stdtypes.rst:5806 msgid ":class:`collections.defaultdict`" msgstr ":class:`collections.defaultdict`" -#: ../../library/stdtypes.rst:5704 +#: ../../library/stdtypes.rst:5807 msgid ":class:`collections.OrderedDict`" msgstr ":class:`collections.OrderedDict`" -#: ../../library/stdtypes.rst:5705 +#: ../../library/stdtypes.rst:5808 msgid ":class:`collections.Counter`" msgstr ":class:`collections.Counter`" -#: ../../library/stdtypes.rst:5706 +#: ../../library/stdtypes.rst:5809 msgid ":class:`collections.ChainMap`" msgstr ":class:`collections.ChainMap`" -#: ../../library/stdtypes.rst:5707 +#: ../../library/stdtypes.rst:5810 msgid ":class:`collections.abc.Awaitable`" msgstr ":class:`collections.abc.Awaitable`" -#: ../../library/stdtypes.rst:5708 +#: ../../library/stdtypes.rst:5811 msgid ":class:`collections.abc.Coroutine`" msgstr ":class:`collections.abc.Coroutine`" -#: ../../library/stdtypes.rst:5709 +#: ../../library/stdtypes.rst:5812 msgid ":class:`collections.abc.AsyncIterable`" msgstr ":class:`collections.abc.AsyncIterable`" -#: ../../library/stdtypes.rst:5710 +#: ../../library/stdtypes.rst:5813 msgid ":class:`collections.abc.AsyncIterator`" msgstr ":class:`collections.abc.AsyncIterator`" -#: ../../library/stdtypes.rst:5711 +#: ../../library/stdtypes.rst:5814 msgid ":class:`collections.abc.AsyncGenerator`" msgstr ":class:`collections.abc.AsyncGenerator`" -#: ../../library/stdtypes.rst:5712 +#: ../../library/stdtypes.rst:5815 msgid ":class:`collections.abc.Iterable`" msgstr ":class:`collections.abc.Iterable`" -#: ../../library/stdtypes.rst:5713 +#: ../../library/stdtypes.rst:5816 msgid ":class:`collections.abc.Iterator`" msgstr ":class:`collections.abc.Iterator`" -#: ../../library/stdtypes.rst:5714 +#: ../../library/stdtypes.rst:5817 msgid ":class:`collections.abc.Generator`" msgstr ":class:`collections.abc.Generator`" -#: ../../library/stdtypes.rst:5715 +#: ../../library/stdtypes.rst:5818 msgid ":class:`collections.abc.Reversible`" msgstr ":class:`collections.abc.Reversible`" -#: ../../library/stdtypes.rst:5716 +#: ../../library/stdtypes.rst:5819 msgid ":class:`collections.abc.Container`" msgstr ":class:`collections.abc.Container`" -#: ../../library/stdtypes.rst:5717 +#: ../../library/stdtypes.rst:5820 msgid ":class:`collections.abc.Collection`" msgstr ":class:`collections.abc.Collection`" -#: ../../library/stdtypes.rst:5718 +#: ../../library/stdtypes.rst:5821 msgid ":class:`collections.abc.Callable`" msgstr ":class:`collections.abc.Callable`" -#: ../../library/stdtypes.rst:5719 +#: ../../library/stdtypes.rst:5822 msgid ":class:`collections.abc.Set`" msgstr ":class:`collections.abc.Set`" -#: ../../library/stdtypes.rst:5720 +#: ../../library/stdtypes.rst:5823 msgid ":class:`collections.abc.MutableSet`" msgstr ":class:`collections.abc.MutableSet`" -#: ../../library/stdtypes.rst:5721 +#: ../../library/stdtypes.rst:5824 msgid ":class:`collections.abc.Mapping`" msgstr ":class:`collections.abc.Mapping`" -#: ../../library/stdtypes.rst:5722 +#: ../../library/stdtypes.rst:5825 msgid ":class:`collections.abc.MutableMapping`" msgstr ":class:`collections.abc.MutableMapping`" -#: ../../library/stdtypes.rst:5723 +#: ../../library/stdtypes.rst:5826 msgid ":class:`collections.abc.Sequence`" msgstr ":class:`collections.abc.Sequence`" -#: ../../library/stdtypes.rst:5724 +#: ../../library/stdtypes.rst:5827 msgid ":class:`collections.abc.MutableSequence`" msgstr ":class:`collections.abc.MutableSequence`" -#: ../../library/stdtypes.rst:5725 +#: ../../library/stdtypes.rst:5828 msgid ":class:`collections.abc.ByteString`" msgstr ":class:`collections.abc.ByteString`" -#: ../../library/stdtypes.rst:5726 +#: ../../library/stdtypes.rst:5829 msgid ":class:`collections.abc.MappingView`" msgstr ":class:`collections.abc.MappingView`" -#: ../../library/stdtypes.rst:5727 +#: ../../library/stdtypes.rst:5830 msgid ":class:`collections.abc.KeysView`" msgstr ":class:`collections.abc.KeysView`" -#: ../../library/stdtypes.rst:5728 +#: ../../library/stdtypes.rst:5831 msgid ":class:`collections.abc.ItemsView`" msgstr ":class:`collections.abc.ItemsView`" -#: ../../library/stdtypes.rst:5729 +#: ../../library/stdtypes.rst:5832 msgid ":class:`collections.abc.ValuesView`" msgstr ":class:`collections.abc.ValuesView`" -#: ../../library/stdtypes.rst:5730 +#: ../../library/stdtypes.rst:5833 msgid ":class:`contextlib.AbstractContextManager`" msgstr ":class:`contextlib.AbstractContextManager`" -#: ../../library/stdtypes.rst:5731 +#: ../../library/stdtypes.rst:5834 msgid ":class:`contextlib.AbstractAsyncContextManager`" msgstr ":class:`contextlib.AbstractAsyncContextManager`" -#: ../../library/stdtypes.rst:5732 +#: ../../library/stdtypes.rst:5835 msgid ":class:`dataclasses.Field`" msgstr ":class:`dataclasses.Field`" -#: ../../library/stdtypes.rst:5733 +#: ../../library/stdtypes.rst:5836 msgid ":class:`functools.cached_property`" msgstr ":class:`functools.cached_property`" -#: ../../library/stdtypes.rst:5734 +#: ../../library/stdtypes.rst:5837 msgid ":class:`functools.partialmethod`" msgstr ":class:`functools.partialmethod`" -#: ../../library/stdtypes.rst:5735 +#: ../../library/stdtypes.rst:5838 msgid ":class:`os.PathLike`" msgstr ":class:`os.PathLike`" -#: ../../library/stdtypes.rst:5736 +#: ../../library/stdtypes.rst:5839 msgid ":class:`queue.LifoQueue`" msgstr ":class:`queue.LifoQueue`" -#: ../../library/stdtypes.rst:5737 +#: ../../library/stdtypes.rst:5840 msgid ":class:`queue.Queue`" msgstr ":class:`queue.Queue`" -#: ../../library/stdtypes.rst:5738 +#: ../../library/stdtypes.rst:5841 msgid ":class:`queue.PriorityQueue`" msgstr ":class:`queue.PriorityQueue`" -#: ../../library/stdtypes.rst:5739 +#: ../../library/stdtypes.rst:5842 msgid ":class:`queue.SimpleQueue`" msgstr ":class:`queue.SimpleQueue`" -#: ../../library/stdtypes.rst:5740 +#: ../../library/stdtypes.rst:5843 msgid ":ref:`re.Pattern `" msgstr ":ref:`re.Pattern `" -#: ../../library/stdtypes.rst:5741 +#: ../../library/stdtypes.rst:5844 msgid ":ref:`re.Match `" msgstr ":ref:`re.Match `" -#: ../../library/stdtypes.rst:5742 +#: ../../library/stdtypes.rst:5845 msgid ":class:`shelve.BsdDbShelf`" msgstr ":class:`shelve.BsdDbShelf`" -#: ../../library/stdtypes.rst:5743 +#: ../../library/stdtypes.rst:5846 msgid ":class:`shelve.DbfilenameShelf`" msgstr ":class:`shelve.DbfilenameShelf`" -#: ../../library/stdtypes.rst:5744 +#: ../../library/stdtypes.rst:5847 msgid ":class:`shelve.Shelf`" msgstr ":class:`shelve.Shelf`" -#: ../../library/stdtypes.rst:5745 +#: ../../library/stdtypes.rst:5848 msgid ":class:`types.MappingProxyType`" msgstr ":class:`types.MappingProxyType`" -#: ../../library/stdtypes.rst:5746 +#: ../../library/stdtypes.rst:5849 msgid ":class:`weakref.WeakKeyDictionary`" msgstr ":class:`weakref.WeakKeyDictionary`" -#: ../../library/stdtypes.rst:5747 +#: ../../library/stdtypes.rst:5850 msgid ":class:`weakref.WeakMethod`" msgstr ":class:`weakref.WeakMethod`" -#: ../../library/stdtypes.rst:5748 +#: ../../library/stdtypes.rst:5851 msgid ":class:`weakref.WeakSet`" msgstr ":class:`weakref.WeakSet`" -#: ../../library/stdtypes.rst:5749 +#: ../../library/stdtypes.rst:5852 msgid ":class:`weakref.WeakValueDictionary`" msgstr ":class:`weakref.WeakValueDictionary`" -#: ../../library/stdtypes.rst:5754 +#: ../../library/stdtypes.rst:5857 msgid "Special Attributes of ``GenericAlias`` objects" msgstr "``GenericAlias`` 物件的特殊屬性" -#: ../../library/stdtypes.rst:5756 +#: ../../library/stdtypes.rst:5859 msgid "All parameterized generics implement special read-only attributes." msgstr "所有參數化泛型都有實作特殊的唯讀屬性。" -#: ../../library/stdtypes.rst:5760 +#: ../../library/stdtypes.rst:5863 msgid "This attribute points at the non-parameterized generic class::" msgstr "此屬性指向非參數化泛型類別: ::" -#: ../../library/stdtypes.rst:5762 +#: ../../library/stdtypes.rst:5865 msgid "" ">>> list[int].__origin__\n" "" @@ -8507,7 +8656,7 @@ msgstr "" ">>> list[int].__origin__\n" "" -#: ../../library/stdtypes.rst:5768 +#: ../../library/stdtypes.rst:5871 msgid "" "This attribute is a :class:`tuple` (possibly of length 1) of generic types " "passed to the original :meth:`~object.__class_getitem__` of the generic " @@ -8516,7 +8665,7 @@ msgstr "" "此屬性是傳遞給泛型類別之原始 :meth:`~object.__class_getitem__` 的泛型型別 :" "class:`tuple`\\ (長度可以為 1): ::" -#: ../../library/stdtypes.rst:5772 +#: ../../library/stdtypes.rst:5875 msgid "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" @@ -8524,7 +8673,7 @@ msgstr "" ">>> dict[str, list[int]].__args__\n" "(, list[int])" -#: ../../library/stdtypes.rst:5778 +#: ../../library/stdtypes.rst:5881 msgid "" "This attribute is a lazily computed tuple (possibly empty) of unique type " "variables found in ``__args__``::" @@ -8532,7 +8681,7 @@ msgstr "" "此屬性是個會被延遲計算 (lazily computed) 的元組(可能為空),包含了在 " "``__args__`` 中找得到的不重複型別變數: ::" -#: ../../library/stdtypes.rst:5781 +#: ../../library/stdtypes.rst:5884 msgid "" ">>> from typing import TypeVar\n" "\n" @@ -8546,7 +8695,7 @@ msgstr "" ">>> list[T].__parameters__\n" "(~T,)" -#: ../../library/stdtypes.rst:5789 +#: ../../library/stdtypes.rst:5892 msgid "" "A ``GenericAlias`` object with :class:`typing.ParamSpec` parameters may not " "have correct ``__parameters__`` after substitution because :class:`typing." @@ -8556,7 +8705,7 @@ msgstr "" "有正確的 ``__parameters__``,因為 :class:`typing.ParamSpec` 主要用於靜態型別" "檢查。" -#: ../../library/stdtypes.rst:5796 +#: ../../library/stdtypes.rst:5899 msgid "" "A boolean that is true if the alias has been unpacked using the ``*`` " "operator (see :data:`~typing.TypeVarTuple`)." @@ -8564,19 +8713,19 @@ msgstr "" "如果別名已使用 ``*`` 運算子解包 (unpack) 則為 true 的布林值(請參閱 :data:" "`~typing.TypeVarTuple`\\ )。" -#: ../../library/stdtypes.rst:5804 +#: ../../library/stdtypes.rst:5907 msgid ":pep:`484` - Type Hints" msgstr ":pep:`484` - 型別提示" -#: ../../library/stdtypes.rst:5805 +#: ../../library/stdtypes.rst:5908 msgid "Introducing Python's framework for type annotations." msgstr "引入 Python 的型別註釋框架。" -#: ../../library/stdtypes.rst:5807 +#: ../../library/stdtypes.rst:5910 msgid ":pep:`585` - Type Hinting Generics In Standard Collections" msgstr ":pep:`585` - 標準集合 (Standard Collections) 中的型別提示泛型" -#: ../../library/stdtypes.rst:5808 +#: ../../library/stdtypes.rst:5911 msgid "" "Introducing the ability to natively parameterize standard-library classes, " "provided they implement the special class method :meth:`~object." @@ -8585,7 +8734,7 @@ msgstr "" "引入原生參數化標準函式庫類別的能力,前提是它們有實作特殊的類別方法 :meth:" "`~object.__class_getitem__`。" -#: ../../library/stdtypes.rst:5812 +#: ../../library/stdtypes.rst:5915 msgid "" ":ref:`Generics`, :ref:`user-defined generics ` and :" "class:`typing.Generic`" @@ -8593,18 +8742,18 @@ msgstr "" ":ref:`Generics`、:ref:`使用者定義泛型 `\\ 和 :class:" "`typing.Generic`" -#: ../../library/stdtypes.rst:5813 +#: ../../library/stdtypes.rst:5916 msgid "" "Documentation on how to implement generic classes that can be parameterized " "at runtime and understood by static type-checkers." msgstr "" "有關如何實作可以在 runtime 參數化並能被靜態型別檢查器理解的泛型類別的文件。" -#: ../../library/stdtypes.rst:5822 +#: ../../library/stdtypes.rst:5925 msgid "Union Type" msgstr "聯合型別 (Union Type)" -#: ../../library/stdtypes.rst:5828 +#: ../../library/stdtypes.rst:5931 msgid "" "A union object holds the value of the ``|`` (bitwise or) operation on " "multiple :ref:`type objects `. These types are intended " @@ -8617,7 +8766,7 @@ msgstr "" "釋 (type annotation) `。與下標 :data:`typing.Union` 相比,聯合型" "別運算式可以讓型別提示語法更清晰簡潔。" -#: ../../library/stdtypes.rst:5835 +#: ../../library/stdtypes.rst:5938 msgid "" "Defines a union object which holds types *X*, *Y*, and so forth. ``X | Y`` " "means either X or Y. It is equivalent to ``typing.Union[X, Y]``. For " @@ -8628,7 +8777,7 @@ msgstr "" "``typing.Union[X, Y]``。舉例來說,下列函式需要一個型別為 :class:`int` 或 :" "class:`float` 的引數: ::" -#: ../../library/stdtypes.rst:5840 +#: ../../library/stdtypes.rst:5943 msgid "" "def square(number: int | float) -> int | float:\n" " return number ** 2" @@ -8636,7 +8785,7 @@ msgstr "" "def square(number: int | float) -> int | float:\n" " return number ** 2" -#: ../../library/stdtypes.rst:5845 +#: ../../library/stdtypes.rst:5948 msgid "" "The ``|`` operand cannot be used at runtime to define unions where one or " "more members is a forward reference. For example, ``int | \"Foo\"``, where " @@ -8649,40 +8798,40 @@ msgstr "" "義類別的參照,將在 runtime 失敗。對於包含向前參照的聯合,請將整個運算式以字串" "呈現,例如 ``\"int | Foo\"``。" -#: ../../library/stdtypes.rst:5853 +#: ../../library/stdtypes.rst:5956 msgid "" "Union objects can be tested for equality with other union objects. Details:" msgstr "聯合物件可以與其他聯合物件一起進行相等性測試。細節如下:" -#: ../../library/stdtypes.rst:5855 +#: ../../library/stdtypes.rst:5958 msgid "Unions of unions are flattened::" msgstr "聯合的聯合會被扁平化: ::" -#: ../../library/stdtypes.rst:5857 +#: ../../library/stdtypes.rst:5960 msgid "(int | str) | float == int | str | float" msgstr "(int | str) | float == int | str | float" -#: ../../library/stdtypes.rst:5859 +#: ../../library/stdtypes.rst:5962 msgid "Redundant types are removed::" msgstr "冗餘型別會被刪除: ::" -#: ../../library/stdtypes.rst:5861 +#: ../../library/stdtypes.rst:5964 msgid "int | str | int == int | str" msgstr "int | str | int == int | str" -#: ../../library/stdtypes.rst:5863 +#: ../../library/stdtypes.rst:5966 msgid "When comparing unions, the order is ignored::" msgstr "比較聯合時,順序會被忽略: ::" -#: ../../library/stdtypes.rst:5865 +#: ../../library/stdtypes.rst:5968 msgid "int | str == str | int" msgstr "int | str == str | int" -#: ../../library/stdtypes.rst:5867 +#: ../../library/stdtypes.rst:5970 msgid "It creates instances of :class:`typing.Union`::" msgstr "它會建立 :class:`typing.Union` 的實例: ::" -#: ../../library/stdtypes.rst:5869 +#: ../../library/stdtypes.rst:5972 msgid "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" @@ -8690,21 +8839,21 @@ msgstr "" "int | str == typing.Union[int, str]\n" "type(int | str) is typing.Union" -#: ../../library/stdtypes.rst:5872 +#: ../../library/stdtypes.rst:5975 msgid "Optional types can be spelled as a union with ``None``::" msgstr "可選型別可以表示為與 ``None`` 的聯合: ::" -#: ../../library/stdtypes.rst:5874 +#: ../../library/stdtypes.rst:5977 msgid "str | None == typing.Optional[str]" msgstr "str | None == typing.Optional[str]" -#: ../../library/stdtypes.rst:5879 +#: ../../library/stdtypes.rst:5982 msgid "" "Calls to :func:`isinstance` and :func:`issubclass` are also supported with a " "union object::" msgstr "聯合物件也支援 :func:`isinstance` 和 :func:`issubclass` 的呼叫: ::" -#: ../../library/stdtypes.rst:5882 +#: ../../library/stdtypes.rst:5985 msgid "" ">>> isinstance(\"\", int | str)\n" "True" @@ -8712,14 +8861,14 @@ msgstr "" ">>> isinstance(\"\", int | str)\n" "True" -#: ../../library/stdtypes.rst:5885 +#: ../../library/stdtypes.rst:5988 msgid "" "However, :ref:`parameterized generics ` in union objects " "cannot be checked::" msgstr "" "然而聯合物件中的\\ :ref:`參數化泛型 `\\ 則無法被檢查: ::" -#: ../../library/stdtypes.rst:5888 +#: ../../library/stdtypes.rst:5991 msgid "" ">>> isinstance(1, int | list[int]) # short-circuit evaluation\n" "True\n" @@ -8729,7 +8878,7 @@ msgid "" "TypeError: isinstance() argument 2 cannot be a parameterized generic" msgstr "" -#: ../../library/stdtypes.rst:5895 +#: ../../library/stdtypes.rst:5998 msgid "" "The user-exposed type for the union object can be accessed from :class:" "`typing.Union` and used for :func:`isinstance` checks::" @@ -8737,7 +8886,7 @@ msgstr "" "構成聯合物件的對使用者公開型別 (user-exposed type) 可以透過 :data:`typing." "Union` 存取並用於 :func:`isinstance` 檢查: ::" -#: ../../library/stdtypes.rst:5898 +#: ../../library/stdtypes.rst:6001 msgid "" ">>> import typing\n" ">>> isinstance(int | str, typing.Union)\n" @@ -8755,7 +8904,7 @@ msgstr "" " File \"\", line 1, in \n" "TypeError: cannot create 'typing.Union' instances" -#: ../../library/stdtypes.rst:5907 +#: ../../library/stdtypes.rst:6010 msgid "" "The :meth:`!__or__` method for type objects was added to support the syntax " "``X | Y``. If a metaclass implements :meth:`!__or__`, the Union may " @@ -8764,7 +8913,7 @@ msgstr "" "新增了型別物件的 :meth:`!__or__` 方法來支援 ``X | Y`` 語法。如果元類別有實" "作 :meth:`!__or__`,則 Union 可以覆寫 (override) 它: ::" -#: ../../library/stdtypes.rst:5911 +#: ../../library/stdtypes.rst:6014 msgid "" ">>> class M(type):\n" "... def __or__(self, other):\n" @@ -8790,32 +8939,32 @@ msgstr "" ">>> int | C\n" "int | C" -#: ../../library/stdtypes.rst:5927 +#: ../../library/stdtypes.rst:6030 msgid ":pep:`604` -- PEP proposing the ``X | Y`` syntax and the Union type." msgstr ":pep:`604` -- PEP 提出 ``X | Y`` 語法和聯合型別。" -#: ../../library/stdtypes.rst:5933 +#: ../../library/stdtypes.rst:6036 msgid "" "Union objects are now instances of :class:`typing.Union`. Previously, they " "were instances of :class:`types.UnionType`, which remains an alias for :" "class:`typing.Union`." msgstr "" -#: ../../library/stdtypes.rst:5940 +#: ../../library/stdtypes.rst:6043 msgid "Other Built-in Types" msgstr "其他內建型別" -#: ../../library/stdtypes.rst:5942 +#: ../../library/stdtypes.rst:6045 msgid "" "The interpreter supports several other kinds of objects. Most of these " "support only one or two operations." msgstr "" -#: ../../library/stdtypes.rst:5949 +#: ../../library/stdtypes.rst:6052 msgid "Modules" msgstr "模組" -#: ../../library/stdtypes.rst:5951 +#: ../../library/stdtypes.rst:6054 msgid "" "The only special operation on a module is attribute access: ``m.name``, " "where *m* is a module and *name* accesses a name defined in *m*'s symbol " @@ -8826,7 +8975,7 @@ msgid "" "*foo* somewhere.)" msgstr "" -#: ../../library/stdtypes.rst:5958 +#: ../../library/stdtypes.rst:6061 msgid "" "A special attribute of every module is :attr:`~object.__dict__`. This is the " "dictionary containing the module's symbol table. Modifying this dictionary " @@ -8837,32 +8986,32 @@ msgid "" "recommended." msgstr "" -#: ../../library/stdtypes.rst:5966 +#: ../../library/stdtypes.rst:6069 msgid "" "Modules built into the interpreter are written like this: ````. If loaded from a file, they are written as ````." msgstr "" -#: ../../library/stdtypes.rst:5974 +#: ../../library/stdtypes.rst:6077 msgid "Classes and Class Instances" msgstr "類別與類別實例" -#: ../../library/stdtypes.rst:5976 +#: ../../library/stdtypes.rst:6079 msgid "See :ref:`objects` and :ref:`class` for these." msgstr "請見 :ref:`objects` 和 :ref:`class`。" -#: ../../library/stdtypes.rst:5982 +#: ../../library/stdtypes.rst:6085 msgid "Functions" msgstr "函式" -#: ../../library/stdtypes.rst:5984 +#: ../../library/stdtypes.rst:6087 msgid "" "Function objects are created by function definitions. The only operation on " "a function object is to call it: ``func(argument-list)``." msgstr "" -#: ../../library/stdtypes.rst:5987 +#: ../../library/stdtypes.rst:6090 msgid "" "There are really two flavors of function objects: built-in functions and " "user-defined functions. Both support the same operation (to call the " @@ -8870,15 +9019,15 @@ msgid "" "types." msgstr "" -#: ../../library/stdtypes.rst:5991 +#: ../../library/stdtypes.rst:6094 msgid "See :ref:`function` for more information." msgstr "更多資訊請見 :ref:`function`。" -#: ../../library/stdtypes.rst:5997 +#: ../../library/stdtypes.rst:6100 msgid "Methods" msgstr "方法" -#: ../../library/stdtypes.rst:6001 +#: ../../library/stdtypes.rst:6104 msgid "" "Methods are functions that are called using the attribute notation. There " "are two flavors: :ref:`built-in methods ` (such as :meth:" @@ -8886,7 +9035,7 @@ msgid "" "methods>`. Built-in methods are described with the types that support them." msgstr "" -#: ../../library/stdtypes.rst:6007 +#: ../../library/stdtypes.rst:6110 msgid "" "If you access a method (a function defined in a class namespace) through an " "instance, you get a special object: a :dfn:`bound method` (also called :ref:" @@ -8899,7 +9048,7 @@ msgid "" "arg-2, ..., arg-n)``." msgstr "" -#: ../../library/stdtypes.rst:6018 +#: ../../library/stdtypes.rst:6121 msgid "" "Like :ref:`function objects `, bound method objects " "support getting arbitrary attributes. However, since method attributes are " @@ -8910,7 +9059,7 @@ msgid "" "underlying function object:" msgstr "" -#: ../../library/stdtypes.rst:6026 +#: ../../library/stdtypes.rst:6129 msgid "" ">>> class C:\n" "... def method(self):\n" @@ -8938,15 +9087,15 @@ msgstr "" ">>> c.method.whoami\n" "'my name is method'" -#: ../../library/stdtypes.rst:6041 +#: ../../library/stdtypes.rst:6144 msgid "See :ref:`instance-methods` for more information." msgstr "更多資訊請見 :ref:`instance-methods`。" -#: ../../library/stdtypes.rst:6049 +#: ../../library/stdtypes.rst:6152 msgid "Code Objects" msgstr "程式碼物件" -#: ../../library/stdtypes.rst:6055 +#: ../../library/stdtypes.rst:6158 msgid "" "Code objects are used by the implementation to represent \"pseudo-compiled\" " "executable Python code such as a function body. They differ from function " @@ -8956,7 +9105,7 @@ msgid "" "`~function.__code__` attribute. See also the :mod:`code` module." msgstr "" -#: ../../library/stdtypes.rst:6062 +#: ../../library/stdtypes.rst:6165 msgid "" "Accessing :attr:`~function.__code__` raises an :ref:`auditing event " "` ``object.__getattr__`` with arguments ``obj`` and " @@ -8965,21 +9114,21 @@ msgstr "" "存取 :attr:`~function.__code__` 會引發一個附帶引數 ``obj`` 與 " "``\"__code__\"`` 的\\ :ref:`稽核事件 ` ``object.__getattr__``。" -#: ../../library/stdtypes.rst:6069 +#: ../../library/stdtypes.rst:6172 msgid "" "A code object can be executed or evaluated by passing it (instead of a " "source string) to the :func:`exec` or :func:`eval` built-in functions." msgstr "" -#: ../../library/stdtypes.rst:6072 +#: ../../library/stdtypes.rst:6175 msgid "See :ref:`types` for more information." msgstr "更多資訊請見 :ref:`types`。" -#: ../../library/stdtypes.rst:6078 +#: ../../library/stdtypes.rst:6181 msgid "Type Objects" msgstr "" -#: ../../library/stdtypes.rst:6084 +#: ../../library/stdtypes.rst:6187 msgid "" "Type objects represent the various object types. An object's type is " "accessed by the built-in function :func:`type`. There are no special " @@ -8987,30 +9136,30 @@ msgid "" "standard built-in types." msgstr "" -#: ../../library/stdtypes.rst:6089 +#: ../../library/stdtypes.rst:6192 msgid "Types are written like this: ````." msgstr "" -#: ../../library/stdtypes.rst:6095 +#: ../../library/stdtypes.rst:6198 msgid "The Null Object" msgstr "Null 物件" -#: ../../library/stdtypes.rst:6097 +#: ../../library/stdtypes.rst:6200 msgid "" "This object is returned by functions that don't explicitly return a value. " "It supports no special operations. There is exactly one null object, named " "``None`` (a built-in name). ``type(None)()`` produces the same singleton." msgstr "" -#: ../../library/stdtypes.rst:6101 +#: ../../library/stdtypes.rst:6204 msgid "It is written as ``None``." msgstr "它被寫為 ``None``。" -#: ../../library/stdtypes.rst:6108 +#: ../../library/stdtypes.rst:6211 msgid "The Ellipsis Object" msgstr "Ellipsis 物件" -#: ../../library/stdtypes.rst:6110 +#: ../../library/stdtypes.rst:6213 msgid "" "This object is commonly used to indicate that something is omitted. It " "supports no special operations. There is exactly one ellipsis object, " @@ -9018,63 +9167,63 @@ msgid "" "the :const:`Ellipsis` singleton." msgstr "" -#: ../../library/stdtypes.rst:6115 +#: ../../library/stdtypes.rst:6218 msgid "It is written as ``Ellipsis`` or ``...``." msgstr "它被寫為 ``Ellipsis`` 或 ``...``。" -#: ../../library/stdtypes.rst:6117 +#: ../../library/stdtypes.rst:6220 msgid "" "In typical use, ``...`` as the ``Ellipsis`` object appears in a few " "different places, for instance:" msgstr "" -#: ../../library/stdtypes.rst:6120 +#: ../../library/stdtypes.rst:6223 msgid "" "In type annotations, such as :ref:`callable arguments ` or :ref:`tuple elements `." msgstr "" -#: ../../library/stdtypes.rst:6123 +#: ../../library/stdtypes.rst:6226 msgid "" "As the body of a function instead of a :ref:`pass statement `." msgstr "" -#: ../../library/stdtypes.rst:6125 +#: ../../library/stdtypes.rst:6228 msgid "" "In third-party libraries, such as `Numpy's slicing and striding `_." msgstr "" -#: ../../library/stdtypes.rst:6128 +#: ../../library/stdtypes.rst:6231 msgid "" "Python also uses three dots in ways that are not ``Ellipsis`` objects, for " "instance:" msgstr "" -#: ../../library/stdtypes.rst:6130 +#: ../../library/stdtypes.rst:6233 msgid "" "Doctest's :const:`ELLIPSIS `, as a pattern for missing " "content." msgstr "" -#: ../../library/stdtypes.rst:6132 +#: ../../library/stdtypes.rst:6235 msgid "" "The default Python prompt of the :term:`interactive` shell when partial " "input is incomplete." msgstr "" -#: ../../library/stdtypes.rst:6134 +#: ../../library/stdtypes.rst:6237 msgid "" "Lastly, the Python documentation often uses three dots in conventional " "English usage to mean omitted content, even in code examples that also use " "them as the ``Ellipsis``." msgstr "" -#: ../../library/stdtypes.rst:6142 +#: ../../library/stdtypes.rst:6245 msgid "The NotImplemented Object" msgstr "NotImplemented 物件" -#: ../../library/stdtypes.rst:6144 +#: ../../library/stdtypes.rst:6247 msgid "" "This object is returned from comparisons and binary operations when they are " "asked to operate on types they don't support. See :ref:`comparisons` for " @@ -9082,64 +9231,64 @@ msgid "" "`type(NotImplemented)()` produces the singleton instance." msgstr "" -#: ../../library/stdtypes.rst:6149 +#: ../../library/stdtypes.rst:6252 msgid "It is written as :code:`NotImplemented`." msgstr "它被寫為 :code:`NotImplemented`。" -#: ../../library/stdtypes.rst:6155 +#: ../../library/stdtypes.rst:6258 msgid "Internal Objects" msgstr "內部物件" -#: ../../library/stdtypes.rst:6157 +#: ../../library/stdtypes.rst:6260 msgid "" "See :ref:`types` for this information. It describes :ref:`stack frame " "objects `, :ref:`traceback objects `, and " "slice objects." msgstr "" -#: ../../library/stdtypes.rst:6165 +#: ../../library/stdtypes.rst:6268 msgid "Special Attributes" msgstr "特殊屬性" -#: ../../library/stdtypes.rst:6167 +#: ../../library/stdtypes.rst:6270 msgid "" "The implementation adds a few special read-only attributes to several object " "types, where they are relevant. Some of these are not reported by the :func:" "`dir` built-in function." msgstr "" -#: ../../library/stdtypes.rst:6174 +#: ../../library/stdtypes.rst:6277 msgid "" "The name of the class, function, method, descriptor, or generator instance." msgstr "" -#: ../../library/stdtypes.rst:6180 +#: ../../library/stdtypes.rst:6283 msgid "" "The :term:`qualified name` of the class, function, method, descriptor, or " "generator instance." msgstr "" -#: ../../library/stdtypes.rst:6188 +#: ../../library/stdtypes.rst:6291 msgid "The name of the module in which a class or function was defined." msgstr "" -#: ../../library/stdtypes.rst:6193 +#: ../../library/stdtypes.rst:6296 msgid "" "The documentation string of a class or function, or ``None`` if undefined." msgstr "" -#: ../../library/stdtypes.rst:6198 +#: ../../library/stdtypes.rst:6301 msgid "" "The :ref:`type parameters ` of generic classes, functions, and :" "ref:`type aliases `. For classes and functions that are not " "generic, this will be an empty tuple." msgstr "" -#: ../../library/stdtypes.rst:6208 +#: ../../library/stdtypes.rst:6311 msgid "Integer string conversion length limitation" msgstr "" -#: ../../library/stdtypes.rst:6210 +#: ../../library/stdtypes.rst:6313 msgid "" "CPython has a global limit for converting between :class:`int` and :class:" "`str` to mitigate denial of service attacks. This limit *only* applies to " @@ -9147,7 +9296,7 @@ msgid "" "binary conversions are unlimited. The limit can be configured." msgstr "" -#: ../../library/stdtypes.rst:6215 +#: ../../library/stdtypes.rst:6318 msgid "" "The :class:`int` type in CPython is an arbitrary length number stored in " "binary form (commonly known as a \"bignum\"). There exists no algorithm that " @@ -9157,24 +9306,24 @@ msgid "" "value such as ``int('1' * 500_000)`` can take over a second on a fast CPU." msgstr "" -#: ../../library/stdtypes.rst:6222 +#: ../../library/stdtypes.rst:6325 msgid "" "Limiting conversion size offers a practical way to avoid :cve:`2020-10735`." msgstr "" -#: ../../library/stdtypes.rst:6224 +#: ../../library/stdtypes.rst:6327 msgid "" "The limit is applied to the number of digit characters in the input or " "output string when a non-linear conversion algorithm would be involved. " "Underscores and the sign are not counted towards the limit." msgstr "" -#: ../../library/stdtypes.rst:6228 +#: ../../library/stdtypes.rst:6331 msgid "" "When an operation would exceed the limit, a :exc:`ValueError` is raised:" msgstr "" -#: ../../library/stdtypes.rst:6230 +#: ../../library/stdtypes.rst:6333 msgid "" ">>> import sys\n" ">>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default.\n" @@ -9198,7 +9347,7 @@ msgid "" ">>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited." msgstr "" -#: ../../library/stdtypes.rst:6250 +#: ../../library/stdtypes.rst:6353 msgid "" "The default limit is 4300 digits as provided in :data:`sys.int_info." "default_max_str_digits `. The lowest limit that can be " @@ -9206,11 +9355,11 @@ msgid "" "str_digits_check_threshold `." msgstr "" -#: ../../library/stdtypes.rst:6255 +#: ../../library/stdtypes.rst:6358 msgid "Verification:" msgstr "" -#: ../../library/stdtypes.rst:6257 +#: ../../library/stdtypes.rst:6360 msgid "" ">>> import sys\n" ">>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info\n" @@ -9228,84 +9377,84 @@ msgstr "" "... '571186405732').to_bytes(53, 'big')\n" "..." -#: ../../library/stdtypes.rst:6270 +#: ../../library/stdtypes.rst:6373 msgid "Affected APIs" msgstr "受影響的 API" -#: ../../library/stdtypes.rst:6272 +#: ../../library/stdtypes.rst:6375 msgid "" "The limitation only applies to potentially slow conversions between :class:" "`int` and :class:`str` or :class:`bytes`:" msgstr "" -#: ../../library/stdtypes.rst:6275 +#: ../../library/stdtypes.rst:6378 msgid "``int(string)`` with default base 10." msgstr "``int(string)`` 以預設的 10 為底。" -#: ../../library/stdtypes.rst:6276 +#: ../../library/stdtypes.rst:6379 msgid "``int(string, base)`` for all bases that are not a power of 2." msgstr "" -#: ../../library/stdtypes.rst:6277 +#: ../../library/stdtypes.rst:6380 msgid "``str(integer)``." msgstr "``str(integer)``。" -#: ../../library/stdtypes.rst:6278 +#: ../../library/stdtypes.rst:6381 msgid "``repr(integer)``." msgstr "``repr(integer)``。" -#: ../../library/stdtypes.rst:6279 +#: ../../library/stdtypes.rst:6382 msgid "" "any other string conversion to base 10, for example ``f\"{integer}\"``, " "``\"{}\".format(integer)``, or ``b\"%d\" % integer``." msgstr "" -#: ../../library/stdtypes.rst:6282 +#: ../../library/stdtypes.rst:6385 msgid "The limitations do not apply to functions with a linear algorithm:" msgstr "" -#: ../../library/stdtypes.rst:6284 +#: ../../library/stdtypes.rst:6387 msgid "``int(string, base)`` with base 2, 4, 8, 16, or 32." msgstr "" -#: ../../library/stdtypes.rst:6285 +#: ../../library/stdtypes.rst:6388 msgid ":func:`int.from_bytes` and :func:`int.to_bytes`." msgstr ":func:`int.from_bytes` 和 :func:`int.to_bytes`。" -#: ../../library/stdtypes.rst:6286 +#: ../../library/stdtypes.rst:6389 msgid ":func:`hex`, :func:`oct`, :func:`bin`." msgstr ":func:`hex`、:func:`oct`、:func:`bin`。" -#: ../../library/stdtypes.rst:6287 +#: ../../library/stdtypes.rst:6390 msgid ":ref:`formatspec` for hex, octal, and binary numbers." msgstr "" -#: ../../library/stdtypes.rst:6288 +#: ../../library/stdtypes.rst:6391 msgid ":class:`str` to :class:`float`." msgstr "" -#: ../../library/stdtypes.rst:6289 +#: ../../library/stdtypes.rst:6392 msgid ":class:`str` to :class:`decimal.Decimal`." msgstr "" -#: ../../library/stdtypes.rst:6292 +#: ../../library/stdtypes.rst:6395 msgid "Configuring the limit" msgstr "設定限制" -#: ../../library/stdtypes.rst:6294 +#: ../../library/stdtypes.rst:6397 msgid "" "Before Python starts up you can use an environment variable or an " "interpreter command line flag to configure the limit:" msgstr "" -#: ../../library/stdtypes.rst:6297 +#: ../../library/stdtypes.rst:6400 msgid "" ":envvar:`PYTHONINTMAXSTRDIGITS`, e.g. ``PYTHONINTMAXSTRDIGITS=640 python3`` " "to set the limit to 640 or ``PYTHONINTMAXSTRDIGITS=0 python3`` to disable " "the limitation." msgstr "" -#: ../../library/stdtypes.rst:6300 +#: ../../library/stdtypes.rst:6403 msgid "" ":option:`-X int_max_str_digits <-X>`, e.g. ``python3 -X " "int_max_str_digits=640``" @@ -9313,7 +9462,7 @@ msgstr "" ":option:`-X int_max_str_digits <-X>`,例如 ``python3 -X " "int_max_str_digits=640``" -#: ../../library/stdtypes.rst:6302 +#: ../../library/stdtypes.rst:6405 msgid "" ":data:`sys.flags.int_max_str_digits` contains the value of :envvar:" "`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`. If both the " @@ -9322,38 +9471,38 @@ msgid "" "int_info.default_max_str_digits` was used during initialization." msgstr "" -#: ../../library/stdtypes.rst:6308 +#: ../../library/stdtypes.rst:6411 msgid "" "From code, you can inspect the current limit and set a new one using these :" "mod:`sys` APIs:" msgstr "" -#: ../../library/stdtypes.rst:6311 +#: ../../library/stdtypes.rst:6414 msgid "" ":func:`sys.get_int_max_str_digits` and :func:`sys.set_int_max_str_digits` " "are a getter and setter for the interpreter-wide limit. Subinterpreters have " "their own limit." msgstr "" -#: ../../library/stdtypes.rst:6315 +#: ../../library/stdtypes.rst:6418 msgid "" "Information about the default and minimum can be found in :data:`sys." "int_info`:" msgstr "" -#: ../../library/stdtypes.rst:6317 +#: ../../library/stdtypes.rst:6420 msgid "" ":data:`sys.int_info.default_max_str_digits ` is the compiled-" "in default limit." msgstr "" -#: ../../library/stdtypes.rst:6319 +#: ../../library/stdtypes.rst:6422 msgid "" ":data:`sys.int_info.str_digits_check_threshold ` is the lowest " "accepted value for the limit (other than 0 which disables it)." msgstr "" -#: ../../library/stdtypes.rst:6326 +#: ../../library/stdtypes.rst:6429 msgid "" "Setting a low limit *can* lead to problems. While rare, code exists that " "contains integer constants in decimal in their source that exceed the " @@ -9365,7 +9514,7 @@ msgid "" "constants is to convert them to ``0x`` hexadecimal form as it has no limit." msgstr "" -#: ../../library/stdtypes.rst:6335 +#: ../../library/stdtypes.rst:6438 msgid "" "Test your application thoroughly if you use a low limit. Ensure your tests " "run with the limit set early via the environment or flag so that it applies " @@ -9373,11 +9522,11 @@ msgid "" "to precompile ``.py`` sources to ``.pyc`` files." msgstr "" -#: ../../library/stdtypes.rst:6341 +#: ../../library/stdtypes.rst:6444 msgid "Recommended configuration" msgstr "建議的配置" -#: ../../library/stdtypes.rst:6343 +#: ../../library/stdtypes.rst:6446 msgid "" "The default :data:`sys.int_info.default_max_str_digits` is expected to be " "reasonable for most applications. If your application requires a different " @@ -9385,11 +9534,11 @@ msgid "" "as these APIs were added in security patch releases in versions before 3.12." msgstr "" -#: ../../library/stdtypes.rst:6348 +#: ../../library/stdtypes.rst:6451 msgid "Example::" msgstr "範例: ::" -#: ../../library/stdtypes.rst:6350 +#: ../../library/stdtypes.rst:6453 msgid "" ">>> import sys\n" ">>> if hasattr(sys, \"set_int_max_str_digits\"):\n" @@ -9411,38 +9560,38 @@ msgstr "" "... elif current_limit < lower_bound:\n" "... sys.set_int_max_str_digits(lower_bound)" -#: ../../library/stdtypes.rst:6360 +#: ../../library/stdtypes.rst:6463 msgid "If you need to disable it entirely, set it to ``0``." msgstr "" -#: ../../library/stdtypes.rst:6364 +#: ../../library/stdtypes.rst:6467 msgid "Footnotes" msgstr "註腳" -#: ../../library/stdtypes.rst:6365 +#: ../../library/stdtypes.rst:6468 msgid "" "Additional information on these special methods may be found in the Python " "Reference Manual (:ref:`customization`)." msgstr "" -#: ../../library/stdtypes.rst:6368 +#: ../../library/stdtypes.rst:6471 msgid "" "As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0]``, " "and similarly for tuples." msgstr "" -#: ../../library/stdtypes.rst:6371 +#: ../../library/stdtypes.rst:6474 msgid "They must have since the parser can't tell the type of the operands." msgstr "" -#: ../../library/stdtypes.rst:6373 +#: ../../library/stdtypes.rst:6476 msgid "" "Cased characters are those with general category property being one of " "\"Lu\" (Letter, uppercase), \"Ll\" (Letter, lowercase), or \"Lt\" (Letter, " "titlecase)." msgstr "" -#: ../../library/stdtypes.rst:6376 +#: ../../library/stdtypes.rst:6479 msgid "" "To format only a tuple you should therefore provide a singleton tuple whose " "only element is the tuple to be formatted." @@ -9455,13 +9604,13 @@ msgstr "built-in(內建)" #: ../../library/stdtypes.rst:13 ../../library/stdtypes.rst:324 #: ../../library/stdtypes.rst:401 ../../library/stdtypes.rst:994 #: ../../library/stdtypes.rst:1184 ../../library/stdtypes.rst:1206 -#: ../../library/stdtypes.rst:1221 ../../library/stdtypes.rst:5084 -#: ../../library/stdtypes.rst:6080 +#: ../../library/stdtypes.rst:1221 ../../library/stdtypes.rst:5187 +#: ../../library/stdtypes.rst:6183 msgid "types" msgstr "type(型別)" #: ../../library/stdtypes.rst:34 ../../library/stdtypes.rst:1221 -#: ../../library/stdtypes.rst:5084 +#: ../../library/stdtypes.rst:5187 msgid "statement" msgstr "statement(陳述式)" @@ -9581,13 +9730,13 @@ msgstr "is not" #: ../../library/stdtypes.rst:165 ../../library/stdtypes.rst:210 #: ../../library/stdtypes.rst:978 ../../library/stdtypes.rst:1184 #: ../../library/stdtypes.rst:1206 ../../library/stdtypes.rst:1371 -#: ../../library/stdtypes.rst:1450 ../../library/stdtypes.rst:1494 -#: ../../library/stdtypes.rst:1615 ../../library/stdtypes.rst:1745 -#: ../../library/stdtypes.rst:3105 ../../library/stdtypes.rst:3124 -#: ../../library/stdtypes.rst:3237 ../../library/stdtypes.rst:4873 -#: ../../library/stdtypes.rst:5084 ../../library/stdtypes.rst:5567 -#: ../../library/stdtypes.rst:5824 ../../library/stdtypes.rst:5999 -#: ../../library/stdtypes.rst:6044 +#: ../../library/stdtypes.rst:1553 ../../library/stdtypes.rst:1597 +#: ../../library/stdtypes.rst:1718 ../../library/stdtypes.rst:1848 +#: ../../library/stdtypes.rst:3208 ../../library/stdtypes.rst:3227 +#: ../../library/stdtypes.rst:3340 ../../library/stdtypes.rst:4976 +#: ../../library/stdtypes.rst:5187 ../../library/stdtypes.rst:5670 +#: ../../library/stdtypes.rst:5927 ../../library/stdtypes.rst:6102 +#: ../../library/stdtypes.rst:6147 msgid "object" msgstr "object(物件)" @@ -9679,9 +9828,9 @@ msgid "arithmetic" msgstr "arithmetic(算術)" #: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:994 -#: ../../library/stdtypes.rst:1184 ../../library/stdtypes.rst:5084 -#: ../../library/stdtypes.rst:6051 ../../library/stdtypes.rst:6065 -#: ../../library/stdtypes.rst:6080 +#: ../../library/stdtypes.rst:1184 ../../library/stdtypes.rst:5187 +#: ../../library/stdtypes.rst:6154 ../../library/stdtypes.rst:6168 +#: ../../library/stdtypes.rst:6183 msgid "built-in function" msgstr "built-in function(內建函式)" @@ -9697,8 +9846,8 @@ msgstr "float" msgid "complex" msgstr "complex(複數)" -#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:2981 -#: ../../library/stdtypes.rst:4241 +#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3084 +#: ../../library/stdtypes.rst:4344 msgid "+ (plus)" msgstr "+ (加號)" @@ -9710,13 +9859,13 @@ msgstr "unary operator(一元運算子)" msgid "binary operator" msgstr "binary operator(二元運算子)" -#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:2981 -#: ../../library/stdtypes.rst:4241 +#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3084 +#: ../../library/stdtypes.rst:4344 msgid "- (minus)" msgstr "- (減號)" -#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:2938 -#: ../../library/stdtypes.rst:4198 +#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3041 +#: ../../library/stdtypes.rst:4301 msgid "* (asterisk)" msgstr "* (星號)" @@ -9728,8 +9877,8 @@ msgstr "/ (斜線)" msgid "//" msgstr "//" -#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:2901 -#: ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:251 ../../library/stdtypes.rst:3004 +#: ../../library/stdtypes.rst:4269 msgid "% (percent)" msgstr "% (百分號)" @@ -9739,7 +9888,7 @@ msgstr "**" #: ../../library/stdtypes.rst:324 ../../library/stdtypes.rst:401 #: ../../library/stdtypes.rst:994 ../../library/stdtypes.rst:1221 -#: ../../library/stdtypes.rst:5084 +#: ../../library/stdtypes.rst:5187 msgid "operations on" msgstr "operations on(操作於)" @@ -9747,8 +9896,8 @@ msgstr "operations on(操作於)" msgid "conjugate() (complex number method)" msgstr "conjugate()(複數方法)" -#: ../../library/stdtypes.rst:343 ../../library/stdtypes.rst:1813 -#: ../../library/stdtypes.rst:3105 ../../library/stdtypes.rst:6080 +#: ../../library/stdtypes.rst:343 ../../library/stdtypes.rst:1916 +#: ../../library/stdtypes.rst:3208 ../../library/stdtypes.rst:6183 msgid "module" msgstr "模組" @@ -9816,7 +9965,7 @@ msgstr "values" msgid "iterator protocol" msgstr "iterator protocol(疊代器協定)" -#: ../../library/stdtypes.rst:891 ../../library/stdtypes.rst:5480 +#: ../../library/stdtypes.rst:891 ../../library/stdtypes.rst:5583 msgid "protocol" msgstr "protocol(協定)" @@ -9842,7 +9991,7 @@ msgstr "container(容器)" msgid "iteration over" msgstr "iteration over(疊代於)" -#: ../../library/stdtypes.rst:994 ../../library/stdtypes.rst:5084 +#: ../../library/stdtypes.rst:994 ../../library/stdtypes.rst:5187 msgid "len" msgstr "len" @@ -9894,7 +10043,7 @@ msgstr "loop over(迴圈)" msgid "immutable" msgstr "immutable(不可變)" -#: ../../library/stdtypes.rst:1184 ../../library/stdtypes.rst:1450 +#: ../../library/stdtypes.rst:1184 ../../library/stdtypes.rst:1553 msgid "tuple" msgstr "tuple(元組)" @@ -9911,14 +10060,14 @@ msgstr "mutable(可變)" msgid "list" msgstr "list(串列)" -#: ../../library/stdtypes.rst:1206 ../../library/stdtypes.rst:3105 -#: ../../library/stdtypes.rst:3237 ../../library/stdtypes.rst:3347 -#: ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:1206 ../../library/stdtypes.rst:3208 +#: ../../library/stdtypes.rst:3340 ../../library/stdtypes.rst:3450 +#: ../../library/stdtypes.rst:4269 msgid "bytearray" msgstr "bytearray(位元組陣列)" -#: ../../library/stdtypes.rst:1221 ../../library/stdtypes.rst:5084 -#: ../../library/stdtypes.rst:5824 ../../library/stdtypes.rst:6080 +#: ../../library/stdtypes.rst:1221 ../../library/stdtypes.rst:5187 +#: ../../library/stdtypes.rst:5927 ../../library/stdtypes.rst:6183 msgid "type" msgstr "type(型別)" @@ -9926,288 +10075,288 @@ msgstr "type(型別)" msgid "assignment" msgstr "assignment(賦值)" -#: ../../library/stdtypes.rst:1221 ../../library/stdtypes.rst:5084 +#: ../../library/stdtypes.rst:1221 ../../library/stdtypes.rst:5187 msgid "del" msgstr "del" -#: ../../library/stdtypes.rst:1494 +#: ../../library/stdtypes.rst:1597 msgid "range" msgstr "range" -#: ../../library/stdtypes.rst:1615 ../../library/stdtypes.rst:1758 -#: ../../library/stdtypes.rst:1805 ../../library/stdtypes.rst:2729 -#: ../../library/stdtypes.rst:2901 +#: ../../library/stdtypes.rst:1718 ../../library/stdtypes.rst:1861 +#: ../../library/stdtypes.rst:1908 ../../library/stdtypes.rst:2832 +#: ../../library/stdtypes.rst:3004 msgid "string" msgstr "string(字串)" -#: ../../library/stdtypes.rst:1615 +#: ../../library/stdtypes.rst:1718 msgid "text sequence type" msgstr "text sequence type(文字序列型別)" -#: ../../library/stdtypes.rst:1615 ../../library/stdtypes.rst:1758 -#: ../../library/stdtypes.rst:1778 +#: ../../library/stdtypes.rst:1718 ../../library/stdtypes.rst:1861 +#: ../../library/stdtypes.rst:1881 msgid "str (built-in class)" msgstr "str(內建類別)" -#: ../../library/stdtypes.rst:1615 +#: ../../library/stdtypes.rst:1718 msgid "(see also string)" msgstr "(亦請見 string)" -#: ../../library/stdtypes.rst:1745 +#: ../../library/stdtypes.rst:1848 msgid "io.StringIO" msgstr "io.StringIO" -#: ../../library/stdtypes.rst:1778 ../../library/stdtypes.rst:3097 +#: ../../library/stdtypes.rst:1881 ../../library/stdtypes.rst:3200 msgid "buffer protocol" msgstr "buffer protocol(緩衝區協定)" -#: ../../library/stdtypes.rst:1778 ../../library/stdtypes.rst:3105 -#: ../../library/stdtypes.rst:3124 ../../library/stdtypes.rst:3347 -#: ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:1881 ../../library/stdtypes.rst:3208 +#: ../../library/stdtypes.rst:3227 ../../library/stdtypes.rst:3450 +#: ../../library/stdtypes.rst:4269 msgid "bytes" msgstr "bytes(位元組)" -#: ../../library/stdtypes.rst:1805 ../../library/stdtypes.rst:3347 +#: ../../library/stdtypes.rst:1908 ../../library/stdtypes.rst:3450 msgid "methods" msgstr "methods(方法)" -#: ../../library/stdtypes.rst:1813 +#: ../../library/stdtypes.rst:1916 msgid "re" msgstr "re" -#: ../../library/stdtypes.rst:2541 ../../library/stdtypes.rst:4020 +#: ../../library/stdtypes.rst:2644 ../../library/stdtypes.rst:4123 msgid "universal newlines" msgstr "universal newlines" -#: ../../library/stdtypes.rst:2541 +#: ../../library/stdtypes.rst:2644 msgid "str.splitlines method" msgstr "str.splitlines 方法" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "! formatted string literal" msgstr "! formatted string literals(! 格式化字串常數)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "formatted string literals" msgstr "formatted string literals(格式化字串常數)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "! f-string" msgstr "! f-string(! f 字串)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "f-strings" msgstr "f-string(f 字串)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "fstring" msgstr "fstring(f 字串)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "interpolated string literal" msgstr "interpolated string literal(插值字串常數)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "formatted literal" msgstr "formatted literal(格式化常數)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "interpolated literal" msgstr "interpolated literal(插值常數)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "{} (curly brackets)" msgstr "{} (花括號)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "in formatted string literal" msgstr "於格式化字串常數中" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "! (exclamation mark)" msgstr "! (驚嘆號)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid ": (colon)" msgstr ": (冒號)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "= (equals)" msgstr "= (等號)" -#: ../../library/stdtypes.rst:2729 +#: ../../library/stdtypes.rst:2832 msgid "for help in debugging using string literals" msgstr "" -#: ../../library/stdtypes.rst:2901 +#: ../../library/stdtypes.rst:3004 msgid "formatting, string (%)" msgstr "formatting(格式化)、字串 (%)" -#: ../../library/stdtypes.rst:2901 +#: ../../library/stdtypes.rst:3004 msgid "interpolation, string (%)" msgstr "interpolation(插值)、字串 (%)" -#: ../../library/stdtypes.rst:2901 +#: ../../library/stdtypes.rst:3004 msgid "formatting, printf" msgstr "formatting(格式化)、printf" -#: ../../library/stdtypes.rst:2901 +#: ../../library/stdtypes.rst:3004 msgid "interpolation, printf" msgstr "interpolation(插值)、printf" -#: ../../library/stdtypes.rst:2901 ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:3004 ../../library/stdtypes.rst:4269 msgid "printf-style formatting" msgstr "printf 風格格式化" -#: ../../library/stdtypes.rst:2901 ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:3004 ../../library/stdtypes.rst:4269 msgid "sprintf-style formatting" msgstr "sprintf 風格格式化" -#: ../../library/stdtypes.rst:2938 ../../library/stdtypes.rst:4198 +#: ../../library/stdtypes.rst:3041 ../../library/stdtypes.rst:4301 msgid "() (parentheses)" msgstr "() (圓括號)" -#: ../../library/stdtypes.rst:2938 ../../library/stdtypes.rst:2981 -#: ../../library/stdtypes.rst:4198 ../../library/stdtypes.rst:4241 +#: ../../library/stdtypes.rst:3041 ../../library/stdtypes.rst:3084 +#: ../../library/stdtypes.rst:4301 ../../library/stdtypes.rst:4344 msgid "in printf-style formatting" msgstr "於 printf 風格格式化" -#: ../../library/stdtypes.rst:2938 ../../library/stdtypes.rst:4198 +#: ../../library/stdtypes.rst:3041 ../../library/stdtypes.rst:4301 msgid ". (dot)" msgstr ". (點)" -#: ../../library/stdtypes.rst:2981 ../../library/stdtypes.rst:4241 +#: ../../library/stdtypes.rst:3084 ../../library/stdtypes.rst:4344 msgid "# (hash)" msgstr "# (井字號)" -#: ../../library/stdtypes.rst:2981 ../../library/stdtypes.rst:4241 +#: ../../library/stdtypes.rst:3084 ../../library/stdtypes.rst:4344 msgid "space" msgstr "space(空白)" -#: ../../library/stdtypes.rst:3097 +#: ../../library/stdtypes.rst:3200 msgid "binary sequence types" msgstr "binary sequence types(二進位序列型別)" -#: ../../library/stdtypes.rst:3105 +#: ../../library/stdtypes.rst:3208 msgid "memoryview" msgstr "memoryview(記憶體視圖)" -#: ../../library/stdtypes.rst:3105 +#: ../../library/stdtypes.rst:3208 msgid "array" msgstr "array(陣列)" -#: ../../library/stdtypes.rst:4020 +#: ../../library/stdtypes.rst:4123 msgid "bytes.splitlines method" msgstr "bytes.splitlines 方法" -#: ../../library/stdtypes.rst:4020 +#: ../../library/stdtypes.rst:4123 msgid "bytearray.splitlines method" msgstr "bytearray.splitlines 方法" -#: ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:4269 msgid "formatting" msgstr "formatting(格式化)" -#: ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:4269 msgid "bytes (%)" msgstr "bytes (%)" -#: ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:4269 msgid "bytearray (%)" msgstr "bytearray (%)" -#: ../../library/stdtypes.rst:4166 +#: ../../library/stdtypes.rst:4269 msgid "interpolation" msgstr "interpolation(插值)" -#: ../../library/stdtypes.rst:4873 +#: ../../library/stdtypes.rst:4976 msgid "set" msgstr "set(集合)" -#: ../../library/stdtypes.rst:5084 +#: ../../library/stdtypes.rst:5187 msgid "mapping" msgstr "mapping(對映)" -#: ../../library/stdtypes.rst:5084 +#: ../../library/stdtypes.rst:5187 msgid "dictionary" msgstr "dictionary(字典)" -#: ../../library/stdtypes.rst:5191 +#: ../../library/stdtypes.rst:5294 msgid "__missing__()" msgstr "__missing__()" -#: ../../library/stdtypes.rst:5480 +#: ../../library/stdtypes.rst:5583 msgid "context manager" msgstr "context manager(情境管理器)" -#: ../../library/stdtypes.rst:5480 +#: ../../library/stdtypes.rst:5583 msgid "context management protocol" msgstr "context management protocol(情境管理協定)" -#: ../../library/stdtypes.rst:5480 +#: ../../library/stdtypes.rst:5583 msgid "context management" msgstr "context management(情境管理)" -#: ../../library/stdtypes.rst:5555 +#: ../../library/stdtypes.rst:5658 msgid "annotation" msgstr "annotation(註記)" -#: ../../library/stdtypes.rst:5555 +#: ../../library/stdtypes.rst:5658 msgid "type annotation; type hint" msgstr "type annotation(型別註記);type hint(型別提示)" -#: ../../library/stdtypes.rst:5567 +#: ../../library/stdtypes.rst:5670 msgid "GenericAlias" msgstr "GenericAlias(泛型別名)" -#: ../../library/stdtypes.rst:5567 +#: ../../library/stdtypes.rst:5670 msgid "Generic" msgstr "Generic(泛型)" -#: ../../library/stdtypes.rst:5567 +#: ../../library/stdtypes.rst:5670 msgid "Alias" msgstr "Alias(別名)" -#: ../../library/stdtypes.rst:5824 +#: ../../library/stdtypes.rst:5927 msgid "Union" msgstr "Union(聯合)" -#: ../../library/stdtypes.rst:5824 +#: ../../library/stdtypes.rst:5927 msgid "union" msgstr "union(聯集)" -#: ../../library/stdtypes.rst:5999 +#: ../../library/stdtypes.rst:6102 msgid "method" msgstr "method(方法)" -#: ../../library/stdtypes.rst:6044 +#: ../../library/stdtypes.rst:6147 msgid "code" msgstr "code(程式碼)" -#: ../../library/stdtypes.rst:6044 +#: ../../library/stdtypes.rst:6147 msgid "code object" msgstr "code object(程式碼物件)" -#: ../../library/stdtypes.rst:6051 +#: ../../library/stdtypes.rst:6154 msgid "compile" msgstr "compile(編譯)" -#: ../../library/stdtypes.rst:6051 +#: ../../library/stdtypes.rst:6154 msgid "__code__ (function object attribute)" msgstr "__code__(函式物件屬性)" -#: ../../library/stdtypes.rst:6065 +#: ../../library/stdtypes.rst:6168 msgid "exec" msgstr "exec" -#: ../../library/stdtypes.rst:6065 +#: ../../library/stdtypes.rst:6168 msgid "eval" msgstr "eval" -#: ../../library/stdtypes.rst:6104 +#: ../../library/stdtypes.rst:6207 msgid "..." msgstr "..." -#: ../../library/stdtypes.rst:6104 +#: ../../library/stdtypes.rst:6207 msgid "ellipsis literal" msgstr "ellipsis literal(刪節號字面值)" From a80e464bce26a282e85f4a7e8db1f84ef4858782 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 13 Jan 2026 03:11:13 +0000 Subject: [PATCH 3/3] sync with cpython 2426c453 --- library/random.po | 72 +++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/library/random.po b/library/random.po index 0614f66beb5..e02ff2d9f48 100644 --- a/library/random.po +++ b/library/random.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-12-20 00:15+0000\n" +"POT-Creation-Date: 2026-01-13 03:09+0000\n" "PO-Revision-Date: 2025-03-07 19:17+0800\n" "Last-Translator: Dr.XYZ \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" @@ -1102,10 +1102,13 @@ msgstr "" "(combinatoric iterators) 中進行隨機選擇:" #: ../../library/random.rst:635 +#, fuzzy msgid "" -"def random_product(*args, repeat=1):\n" -" \"Random selection from itertools.product(*args, **kwds)\"\n" -" pools = [tuple(pool) for pool in args] * repeat\n" +"import random\n" +"\n" +"def random_product(*iterables, repeat=1):\n" +" \"Random selection from itertools.product(*iterables, repeat=repeat)\"\n" +" pools = tuple(map(tuple, iterables)) * repeat\n" " return tuple(map(random.choice, pools))\n" "\n" "def random_permutation(iterable, r=None):\n" @@ -1129,7 +1132,22 @@ msgid "" " pool = tuple(iterable)\n" " n = len(pool)\n" " indices = sorted(random.choices(range(n), k=r))\n" -" return tuple(pool[i] for i in indices)" +" return tuple(pool[i] for i in indices)\n" +"\n" +"def random_derangement(iterable):\n" +" \"Choose a permutation where no element stays in its original position." +"\"\n" +" seq = tuple(iterable)\n" +" if len(seq) < 2:\n" +" if not seq:\n" +" return ()\n" +" raise IndexError('No derangments to choose from')\n" +" perm = list(range(len(seq)))\n" +" start = tuple(perm)\n" +" while True:\n" +" random.shuffle(perm)\n" +" if all(p != q for p, q in zip(start, perm)):\n" +" return tuple([seq[i] for i in perm])" msgstr "" "def random_product(*args, repeat=1):\n" " \"從 itertools.product(*args, **kwds) 中隨機選擇\"\n" @@ -1157,7 +1175,7 @@ msgstr "" " indices = sorted(random.choices(range(n), k=r))\n" " return tuple(pool[i] for i in indices)" -#: ../../library/random.rst:664 +#: ../../library/random.rst:750 msgid "" "The default :func:`.random` returns multiples of 2⁻⁵³ in the range *0.0 ≤ x " "< 1.0*. All such numbers are evenly spaced and are exactly representable as " @@ -1169,7 +1187,7 @@ msgstr "" "均勻分佈的,並且可以完全表示為 Python float。但是,該間隔中的許多其他可表示" "的 float 不是可能的選擇。 例如 ``0.05954861408025609`` 不是 2⁻⁵³ 的整數倍。" -#: ../../library/random.rst:670 +#: ../../library/random.rst:756 msgid "" "The following recipe takes a different approach. All floats in the interval " "are possible selections. The mantissa comes from a uniform distribution of " @@ -1181,7 +1199,7 @@ msgstr "" "數 < 2⁵³* 範圍內的整數均勻分佈。指數來自幾何分佈,其中小於 *-53* 的指數的出現" "頻率是下一個較大指數的一半。" -#: ../../library/random.rst:678 +#: ../../library/random.rst:764 msgid "" "from random import Random\n" "from math import ldexp\n" @@ -1211,7 +1229,7 @@ msgstr "" " exponent += x.bit_length() - 32\n" " return ldexp(mantissa, exponent)" -#: ../../library/random.rst:692 +#: ../../library/random.rst:778 msgid "" "All :ref:`real valued distributions ` in the " "class will use the new method::" @@ -1219,7 +1237,7 @@ msgstr "" "Class 中的所有\\ :ref:`實數分佈 `\\ 都將使用新方" "法: ::" -#: ../../library/random.rst:695 +#: ../../library/random.rst:781 msgid "" ">>> fr = FullRandom()\n" ">>> fr.random()\n" @@ -1233,7 +1251,7 @@ msgstr "" ">>> fr.expovariate(0.25)\n" "8.87925541791544" -#: ../../library/random.rst:701 +#: ../../library/random.rst:787 msgid "" "The recipe is conceptually equivalent to an algorithm that chooses from all " "the multiples of 2⁻¹⁰⁷⁴ in the range *0.0 ≤ x < 1.0*. All such numbers are " @@ -1246,7 +1264,7 @@ msgstr "" "示的 Python float。(2⁻¹⁰⁷⁴ 是最小為正的非正規化 float,等於 ``math." "ulp(0.0)``)" -#: ../../library/random.rst:710 +#: ../../library/random.rst:796 msgid "" "`Generating Pseudo-random Floating-Point Values `_ a paper by Allen B. Downey describing " @@ -1257,68 +1275,68 @@ msgstr "" "pdf>`_ Allen B. Downey 的一篇論文描述了產生比通常由 :func:`.random` 產生的 " "float 更 fine-grained(細粒的)的方法。" -#: ../../library/random.rst:718 +#: ../../library/random.rst:804 msgid "Command-line usage" msgstr "命令列用法" -#: ../../library/random.rst:722 +#: ../../library/random.rst:808 msgid "The :mod:`!random` module can be executed from the command line." msgstr ":mod:`!random` 模組可以從命令列執行。" -#: ../../library/random.rst:724 +#: ../../library/random.rst:810 msgid "" "python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]" msgstr "" "python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]" -#: ../../library/random.rst:728 +#: ../../library/random.rst:814 msgid "The following options are accepted:" msgstr "接受以下選項:" -#: ../../library/random.rst:734 +#: ../../library/random.rst:820 msgid "Show the help message and exit." msgstr "顯示幫助訊息並退出。" -#: ../../library/random.rst:739 +#: ../../library/random.rst:825 msgid "Print a random choice, using :meth:`choice`." msgstr "列印一個隨機選擇,使用 :meth:`choice`。" -#: ../../library/random.rst:744 +#: ../../library/random.rst:830 msgid "" "Print a random integer between 1 and N inclusive, using :meth:`randint`." msgstr "列印 1 到 N(含)之間的隨機整數,使用 :meth:`randint`。" -#: ../../library/random.rst:749 +#: ../../library/random.rst:835 msgid "" "Print a random floating-point number between 0 and N inclusive, using :meth:" "`uniform`." msgstr "列印 0 到 N(含)之間的隨機浮點數,使用 :meth:`uniform`。" -#: ../../library/random.rst:752 +#: ../../library/random.rst:838 msgid "If no options are given, the output depends on the input:" msgstr "如果未給定選項,則輸出取決於輸入:" -#: ../../library/random.rst:754 +#: ../../library/random.rst:840 msgid "String or multiple: same as :option:`--choice`." msgstr "字串或多個:與 :option:`--choice` 相同。" -#: ../../library/random.rst:755 +#: ../../library/random.rst:841 msgid "Integer: same as :option:`--integer`." msgstr "整數:與 :option:`--integer` 相同。" -#: ../../library/random.rst:756 +#: ../../library/random.rst:842 msgid "Float: same as :option:`--float`." msgstr "浮點數:與 :option:`--float` 相同。" -#: ../../library/random.rst:761 +#: ../../library/random.rst:847 msgid "Command-line example" msgstr "命令列範例" -#: ../../library/random.rst:763 +#: ../../library/random.rst:849 msgid "Here are some examples of the :mod:`!random` command-line interface:" msgstr "以下是 :mod:`!random` 命令列介面的一些範例:" -#: ../../library/random.rst:765 +#: ../../library/random.rst:851 msgid "" "$ # Choose one at random\n" "$ python -m random egg bacon sausage spam \"Lobster Thermidor aux crevettes "