diff --git a/library/functions.po b/library/functions.po index eac3c0cc25..a50c6f095f 100644 --- a/library/functions.po +++ b/library/functions.po @@ -3,16 +3,17 @@ # Translators: # Adrian Liaw , 2018 # nienzu , 2018 -# Matt Wang , 2021 +# Matt Wang , 2021, 2026 # Phil Lin , 2022 # Steven Hsu , 2023 +# Weilin Du <1372449351@qq.com>, 2025 msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-03-12 00:16+0000\n" -"PO-Revision-Date: 2024-05-06 17:06+0800\n" -"Last-Translator: KNChiu \n" +"POT-Creation-Date: 2026-04-09 18:54+0800\n" +"PO-Revision-Date: 2025-07-28 21:38+0800\n" +"Last-Translator: Weilin Du <1372449351@qq.com>\n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" "Language: zh_TW\n" @@ -461,8 +462,8 @@ msgid "" "exhausted, otherwise :exc:`StopAsyncIteration` is raised." msgstr "" "呼叫 *async_iterator* 的 :meth:`~object.__anext__` 方法,回傳 :term:" -"`awaitable`。等待返回疊代器的下一個值。如果指定 *default*,當疊代器結束時會返" -"回該值,否則會引發 :exc:`StopAsyncIteration` 。" +"`awaitable`。等待回傳疊代器的下一個值。如果指定 *default*,當疊代器結束時會回" +"傳該值,否則會引發 :exc:`StopAsyncIteration` 。" #: ../../library/functions.rst:104 msgid "" @@ -935,7 +936,7 @@ msgstr "" msgid "" "Convert a single string or number to a complex number, or create a complex " "number from real and imaginary parts." -msgstr "" +msgstr "將單一字串或數字轉換為複數,或從實部和虛部建立複數。" #: ../../library/functions.rst:384 ../../library/functions.rst:760 #: ../../library/functions.rst:1008 @@ -992,6 +993,14 @@ msgid "" "token:`~float:complexvalue` production rule in the following grammar, after " "parentheses and leading and trailing whitespace characters are removed:" msgstr "" +"如果引數是字串,它必須包含實數部分(格式與 :func:`float` 相同)或虛數部分(格" +"式相同,但後綴為 ``'j'`` 或 ``'J'``),或同時包含實數部分和虛數部分(在這種情" +"況下,虛數部分的符號是必須的)。字串可以選擇以空白和圓括號 ``'('`` 和 " +"``')'`` 包圍,這些都會被忽略。字串在 ``'+'``、``'-'``、``'j'`` 或 ``'J'`` 後" +"綴和十進位數字之間不能包含空白。例如,``complex('1+2j')`` 沒有問題," +"但 ``complex('1 + 2j')`` 會引發 :exc:`ValueError`。更精確地說,輸入必須符合以" +"下文法中的 :token:`~float:complexvalue` 產生規則,在去除括號和前後空白字元之" +"後:" #: ../../library/functions.rst:424 msgid "" @@ -1018,6 +1027,11 @@ msgid "" "imaginary component ``real.imag+imag.real``. If one of arguments is a real " "number, only its real component is used in the above expressions." msgstr "" +"如果提供兩個引數或使用關鍵字引數,每個引數可以是任何數值型別(包括複數)。如" +"果兩個引數都是實數,則回傳一個有實數分量 *real* 和虛數分量 *imag* 的複數。如" +"果兩個引數都是複數,則回傳一個包含實數分量 ``real.real-imag.imag`` 和虛數分" +"量 ``real.imag+imag.real`` 的複數。如果其中一個引數是實數,則在上述運算式中只" +"使用其實數分量。" #: ../../library/functions.rst:443 msgid "" @@ -1027,7 +1041,7 @@ msgstr "" #: ../../library/functions.rst:445 msgid "If all arguments are omitted, returns ``0j``." -msgstr "" +msgstr "如果省略所有引數,則回傳 ``0j``。" #: ../../library/functions.rst:447 msgid "The complex type is described in :ref:`typesnumeric`." @@ -1215,27 +1229,27 @@ msgstr "" #: ../../library/functions.rst:0 msgid "Parameters" -msgstr "" +msgstr "參數" #: ../../library/functions.rst:582 msgid "A Python expression." -msgstr "" +msgstr "一個 Python 運算式。" #: ../../library/functions.rst:586 msgid "The global namespace (default: ``None``)." -msgstr "" +msgstr "全域命名空間(預設值:``None``)。" #: ../../library/functions.rst:590 msgid "The local namespace (default: ``None``)." -msgstr "" +msgstr "區域命名空間(預設:``None``)。" #: ../../library/functions.rst:0 msgid "Returns" -msgstr "" +msgstr "回傳值" #: ../../library/functions.rst:594 msgid "The result of the evaluated expression." -msgstr "" +msgstr "被求值的運算式之結果。" #: ../../library/functions.rst:0 msgid "raises" @@ -1243,7 +1257,7 @@ msgstr "引發" #: ../../library/functions.rst:595 msgid "Syntax errors are reported as exceptions." -msgstr "" +msgstr "語法錯誤會報告為例外。" #: ../../library/functions.rst:599 ../../library/functions.rst:661 msgid "" @@ -1332,13 +1346,13 @@ msgstr "" #: ../../library/functions.rst:648 ../../library/functions.rst:726 msgid "The *globals* and *locals* arguments can now be passed as keywords." -msgstr "" +msgstr "*globals* 和 *locals* 引數現在可以作為關鍵字傳遞。" #: ../../library/functions.rst:652 ../../library/functions.rst:730 msgid "" "The semantics of the default *locals* namespace have been adjusted as " "described for the :func:`locals` builtin." -msgstr "" +msgstr "如 :func:`locals` 內建物件所述,已調整預設 *locals* 命名空間的語意。" #: ../../library/functions.rst:664 msgid "" @@ -1384,6 +1398,9 @@ msgid "" "access variables assigned at the top level (as the \"top level\" variables " "are treated as class variables in a class definition)." msgstr "" +"當 ``exec`` 得到兩個獨立的物件作為 *globals* 和 *locals*,程式碼會被執行,就" +"像它被嵌入在類別定義中一樣。這表示在執行的程式碼中定義的函式和類別將無法存取" +"在頂層指定的變數(因為在類別定義中,「頂層」變數被視為類別變數)。" #: ../../library/functions.rst:691 msgid "" @@ -1820,7 +1837,7 @@ msgstr "" msgid "" "Return an integer object constructed from a number or a string, or return " "``0`` if no arguments are given." -msgstr "" +msgstr "回傳一個由數字或字串所構成的整數物件,若沒有給引數則回傳 ``0``。" #: ../../library/functions.rst:1010 msgid "" @@ -2060,7 +2077,7 @@ 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 "" +msgstr "回傳代表目前區域符號表的對映物件,變數名稱為鍵,目前綁定的參照為值。" #: ../../library/functions.rst:1162 msgid "" @@ -2068,18 +2085,22 @@ msgid "" "single namespace, this function returns the same namespace as :func:" "`globals`." msgstr "" +"在模組作用域,以及使用 :func:`exec` 或 :func:`eval` 單一命名空間時,此函式會" +"回傳與 :func:`globals` 相同的命名空間。" #: ../../library/functions.rst:1166 msgid "" "At class scope, it returns the namespace that will be passed to the " "metaclass constructor." -msgstr "" +msgstr "在類別作用域中,它會回傳將傳遞給元類別 (metaclass) 建構函式的命名空間。" #: ../../library/functions.rst:1169 msgid "" "When using ``exec()`` or ``eval()`` with separate local and global " "arguments, it returns the local namespace passed in to the function call." msgstr "" +"當使用 ``exec()`` 或 ``eval()``,並分別使用本機和全局參數時,它會回傳傳入函式" +"呼叫的本機命名空間。" #: ../../library/functions.rst:1172 msgid "" @@ -2090,6 +2111,10 @@ msgid "" "deleting local variables will immediately affect the contents of the " "returned mapping object." msgstr "" +"在上述所有情況下,在指定的執行框架中,每次呼叫 ``locals()`` 都會回傳\\ *相" +"同*\\ 的對映物件。透過 ``locals()`` 回傳的對映物件所做的變更,會以被指派、重" +"新指派或刪除的區域變數的形式顯示,而指派、重新指派或刪除區域變數會立即影響回" +"傳的對映物件的內容。" #: ../../library/functions.rst:1179 msgid "" @@ -2102,6 +2127,11 @@ msgid "" "variables and nonlocal cell references does *not* affect the contents of " "previously returned dictionaries." msgstr "" +"在\\ :term:`optimized scope` 中(包括函式、產生器和協程),每次呼" +"叫 ``locals()`` 都會回傳一個新的字典,其中包含函式的區域變數和任何非區域 " +"cell 參照的目前綁定。在這種情況下,透過回傳的字典所做的名稱綁定變更,\\ **不" +"會**\\ 寫回對應的區域變數或非區域 cell 參照,而且指派、重新指派或刪除區域變數" +"和非區域 cell 參照,\\ **不會**\\ 影響先前回傳字典的內容。" #: ../../library/functions.rst:1188 msgid "" @@ -2111,18 +2141,23 @@ msgid "" "other scopes, it behaves as if the comprehension were running as a nested " "function." msgstr "" +"在函式、產生器或協程中作為綜合運算的一部分呼叫 ``locals()`` 等同於在包含的作" +"用域中呼叫它,但綜合運算已初始化的疊代變數將被包含在內。在其他作用域中,它的" +"行為就像綜合運算作為巢狀函式運行一樣。" #: ../../library/functions.rst:1194 msgid "" "Calling ``locals()`` as part of a generator expression is equivalent to " "calling it in a nested generator function." msgstr "" +"呼叫 ``locals()`` 作為產生器運算式的一部分,等同於在巢狀的產生器函式中呼叫" +"它。" #: ../../library/functions.rst:1197 msgid "" "The behaviour of ``locals()`` in a comprehension has been updated as " "described in :pep:`709`." -msgstr "" +msgstr "如 :pep:`709` 所述,更新了綜合運算中 ``locals()`` 的行為。" #: ../../library/functions.rst:1201 msgid "" @@ -2132,6 +2167,9 @@ msgid "" "being defined, the behaviour in other scopes remains unchanged from previous " "versions." msgstr "" +"作為 :pep:`667` 的一部分,現在定義了變更此函式回傳的對映物件的語意。" +"在 :term:`optimized scopes ` 中的行為現在如上所述。除了被定" +"義外,其他作用域中的行為與先前版本保持不變。" #: ../../library/functions.rst:1211 msgid "" @@ -2180,8 +2218,8 @@ msgid "" msgstr "" "這個函式有兩個選擇性的僅限關鍵字引數。*key* 引數能指定單一引數所使用的排序函" "式,如同 :meth:`list.sort` 的使用方式。*default* 引數是當 iterable 為空時回傳" -"的物件。如果 iterable 為空,並且沒有提供 *default*,則會引發 :exc:" -"`ValueError`。" +"的物件。如果 iterable 為空,並且沒有提供 *default*,則會引" +"發 :exc:`ValueError`。" #: ../../library/functions.rst:1242 msgid "" @@ -2243,8 +2281,8 @@ msgid "" "iterator is exhausted, otherwise :exc:`StopIteration` is raised." msgstr "" "透過呼叫 :term:`iterator` 的 :meth:`~iterator.__next__` method 取得下一個元" -"素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引發 :" -"exc:`StopIteration`。" +"素。如果 iterator 耗盡,則回傳給定的預設值 *default*,如果沒有預設值則引" +"發 :exc:`StopIteration`。" #: ../../library/functions.rst:1302 msgid "" @@ -2981,6 +3019,8 @@ msgid "" "\"getter\" for a read-only attribute with the same name, and it sets the " "docstring for *voltage* to \"Get the current voltage.\"" msgstr "" +"``@property`` 裝飾器將 :meth:`!voltage` 方法變成同名唯讀屬性的 \"getter\",並" +"將 *voltage* 的說明字串設成 \"Get the current voltage\"。" #: ../../library/functions.rst:1696 msgid "" @@ -2989,6 +3029,9 @@ msgid "" "accessor function set to the decorated function. This is best explained " "with an example:" msgstr "" +"一個屬性物件有 ``getter``、``setter`` 和 ``deleter`` 方法,這些方法可作為裝飾" +"器使用,建立一個屬性的副本,並將相應的存取函式設定為被裝飾的函式。最好用一個" +"範例來說明:" #: ../../library/functions.rst:1701 msgid "" @@ -3032,28 +3075,33 @@ msgid "" "additional functions the same name as the original property (``x`` in this " "case.)" msgstr "" +"此程式碼與第一個範例完全相等。請務必賦予附加函式與原始屬性相同的名稱(在此例" +"中為 ``x``)。" #: ../../library/functions.rst:1724 msgid "" "The returned property object also has the attributes ``fget``, ``fset``, and " "``fdel`` corresponding to the constructor arguments." msgstr "" +"回傳的屬性物件也有對應於建構函式引數的屬性 ``fget``、``fset`` 和 ``fdel``。" #: ../../library/functions.rst:1727 msgid "The docstrings of property objects are now writeable." -msgstr "" +msgstr "屬性物件的 docstrings 現在可以寫入。" #: ../../library/functions.rst:1732 msgid "" "Attribute holding the name of the property. The name of the property can be " "changed at runtime." -msgstr "" +msgstr "持有屬性名稱的屬性。屬性名稱可在 runtime 變更。" #: ../../library/functions.rst:1743 msgid "" "Rather than being a function, :class:`range` is actually an immutable " "sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`." msgstr "" +"與其說是函式,:class:`range` 實際上是一個不可變的序列型別," +"如 :ref:`typesseq-range` 和 :ref:`typesseq` 所述。" #: ../../library/functions.rst:1749 msgid "" @@ -3067,10 +3115,16 @@ msgid "" "method. If :func:`sys.displayhook` is not accessible, this function will " "raise :exc:`RuntimeError`." msgstr "" +"回傳一個包含物件可列印表示的字串。對於許多型別,這個函式會嘗試回傳一個字串," +"當傳遞給 :func:`eval` 時,這個字串會產生一個具有相同值的物件;否則,這個表示" +"是一個用角括弧括起來的字串,包含物件型別的名稱,以及額外的資訊,通常包括物件" +"的名稱和位址。一個類別可以透過定義 :meth:`~object.__repr__` 方法來控制這個函" +"式對其實例的回傳值。如果 :func:`sys.displayhook` 不可存取,這個函式會引" +"發 :exc:`RuntimeError`。" #: ../../library/functions.rst:1760 msgid "This class has a custom representation that can be evaluated::" -msgstr "" +msgstr "這個類別有一個自訂的表示,可以被求值: ::" #: ../../library/functions.rst:1762 msgid "" @@ -3104,6 +3158,8 @@ msgid "" "*ndigits* is omitted or is ``None``, it returns the nearest integer to its " "input." msgstr "" +"回傳小數點後四捨五入到 *ndigits* 精度的 *number*。如果省略 *ndigits* 或為 " +"``None``,則會回傳最接近其輸入的整數。" #: ../../library/functions.rst:1785 msgid "" @@ -3654,6 +3710,8 @@ msgid "" "will ignore the remaining items in the longer iterables, cutting off the " "result to the length of the shortest iterable::" msgstr "" +"預設情況下,:func:`zip` 會在最短的可疊代物件用盡時停止。它會忽略較長可疊代物" +"件中的剩餘項目,將結果截斷到最短可疊代物件的長度: ::" #: ../../library/functions.rst:2172 msgid "" @@ -3669,6 +3727,8 @@ msgid "" "equal length. In such cases, it's recommended to use the ``strict=True`` " "option. Its output is the same as regular :func:`zip`::" msgstr "" +":func:`zip` 常常用於可疊代物件被假設等長的情況。在這種情況下,建議使用 " +"``strict=True`` 選項。它的輸出與一般的 :func:`zip` 相同: ::" #: ../../library/functions.rst:2179 msgid "" @@ -3683,6 +3743,8 @@ msgid "" "Unlike the default behavior, it raises a :exc:`ValueError` if one iterable " "is exhausted before the others:" msgstr "" +"與預設行為不同的是,如果有一個可疊代物件先於其他可疊代物件耗盡,它會引" +"發 :exc:`ValueError`:" #: ../../library/functions.rst:2200 msgid "" @@ -3690,6 +3752,8 @@ msgid "" "different lengths will be silenced, possibly manifesting as a hard-to-find " "bug in another part of the program." msgstr "" +"如果沒有 ``strict=True`` 引數,任何導致可疊代物件長度不同的 bug 都會被隱藏," +"可能會在程式的其他部分表現為難以發現的 bug。" #: ../../library/functions.rst:2204 msgid "" @@ -3697,16 +3761,20 @@ msgid "" "iterables have the same length. This is done by :func:`itertools." "zip_longest`." msgstr "" +"較短的可疊代物件可以填充常數值,使所有可疊代物件的長度相同。這可以透" +"過 :func:`itertools.zip_longest` 來完成。" #: ../../library/functions.rst:2208 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 "" +"邊界情況:對於單一可疊代引數,:func:`zip` 會回傳一個 1-tuple 的疊代器。如果沒" +"有引數,它會回傳一個空的疊代器。" #: ../../library/functions.rst:2211 msgid "Tips and tricks:" -msgstr "" +msgstr "秘訣與技巧:" #: ../../library/functions.rst:2213 msgid "" @@ -3716,12 +3784,16 @@ msgid "" "``n`` times so that each output tuple has the result of ``n`` calls to the " "iterator. This has the effect of dividing the input into n-length chunks." msgstr "" +"可疊代物件的從左至右求值順序是有保證的。這使得使用 ``zip(*[iter(s)]*n, " +"strict=True)`` 將資料序列聚類為 n 個長度群組的慣用語成為可能。這會重複\\ *相" +"同的*\\ 疊代器 ``n`` 次,因此每個輸出 tuple 會有 ``n`` 次呼叫疊代器的結果。" +"這樣做的效果是將輸入分割成 n 個長度的區塊。" #: ../../library/functions.rst:2219 msgid "" ":func:`zip` in conjunction with the ``*`` operator can be used to unzip a " "list::" -msgstr "" +msgstr ":func:`zip` 與 ``*`` 運算子結合可以用來解壓縮 (unzip) 一個 list: ::" #: ../../library/functions.rst:2222 msgid "" @@ -3750,6 +3822,8 @@ msgid "" "This is an advanced function that is not needed in everyday Python " "programming, unlike :func:`importlib.import_module`." msgstr "" +"這是一個進階的函式,不像 :func:`importlib.import_module`,這在日常 Python 程" +"式設計中並不需要。" #: ../../library/functions.rst:2245 msgid "" @@ -3762,6 +3836,12 @@ msgid "" "implementation is in use. Direct use of :func:`__import__` is also " "discouraged in favor of :func:`importlib.import_module`." msgstr "" +"這個函式被 :keyword:`import` 陳述式所叫用。它可以被取代(透過引" +"入 :mod:`builtins` 模組並指定給 ``builtins.__import__``),以改變 :keyword:`!" +"import` 陳述式的語意,但這樣做是\\ **強烈**\\ 不鼓勵的,因為通常使用 import " +"鉤子(見 :pep:`302`)來達到相同的目的會比較簡單,而且也不會造成假設使用預" +"設 import 實作的程式碼問題。我們也不鼓勵直接使用 :func:`__import__`,而應改" +"用 :func:`importlib.import_module`。" #: ../../library/functions.rst:2254 msgid "" @@ -3772,6 +3852,10 @@ msgid "" "does not use its *locals* argument at all and uses its *globals* only to " "determine the package context of the :keyword:`import` statement." msgstr "" +"這個函式引入 *name* 模組,可能會使用給定的 *globals* 和 *locals* 來決定如何在" +"套件情境中解釋這個名稱。*fromlist* 給出應該從 *name* 給出的模組引入的物件或子" +"模組的名稱。標準的實作完全不使用 *locals* 引數,而只使用 *globals* 來決" +"定 :keyword:`import` 陳述式的套件情境。" #: ../../library/functions.rst:2261 msgid "" @@ -3781,6 +3865,9 @@ msgid "" "directory of the module calling :func:`__import__` (see :pep:`328` for the " "details)." msgstr "" +"*level* 指定使用絕對或相對引入。``0``\\(預設)表示只執行絕對引入。*level* 的正" +"值表示相對於呼叫 :func:`__import__` 的模組目錄要搜尋的父目錄數目(參" +"見 :pep:`328` 以了解詳情)。" #: ../../library/functions.rst:2267 msgid "" @@ -3789,12 +3876,15 @@ msgid "" "module named by *name*. However, when a non-empty *fromlist* argument is " "given, the module named by *name* is returned." msgstr "" +"當 *name* 變數的形式是 ``package.module`` 時,通常會回傳最上層的套件(直到第" +"一個點為止的名稱),而\\ *不是* *name* 所命名的模組。然而,當給予一個非空的 " +"*fromlist* 引數時,會回傳以 *name* 命名的模組。" #: ../../library/functions.rst:2272 msgid "" "For example, the statement ``import spam`` results in bytecode resembling " "the following code::" -msgstr "" +msgstr "例如,陳述式 ``import spam`` 會產生類似以下程式碼的位元組碼 (bytecode): ::" #: ../../library/functions.rst:2275 msgid "spam = __import__('spam', globals(), locals(), [], 0)" @@ -3802,7 +3892,7 @@ msgstr "spam = __import__('spam', globals(), locals(), [], 0)" #: ../../library/functions.rst:2277 msgid "The statement ``import spam.ham`` results in this call::" -msgstr "" +msgstr "陳述式 ``import spam.ham`` 的結果是這樣的呼叫: ::" #: ../../library/functions.rst:2279 msgid "spam = __import__('spam.ham', globals(), locals(), [], 0)" @@ -3813,12 +3903,14 @@ 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 "" +"請注意 :func:`__import__` 在這裡如何回傳頂層模組(toplevel module),因為這是" +"由 :keyword:`import` 陳述式綁定名稱的物件。" #: ../../library/functions.rst:2284 msgid "" "On the other hand, the statement ``from spam.ham import eggs, sausage as " "saus`` results in ::" -msgstr "" +msgstr "另一方面,陳述式 ``from spam.ham import eggs, sausage as saus`` 結果是: ::" #: ../../library/functions.rst:2287 msgid "" @@ -3836,24 +3928,30 @@ msgid "" "this object, the names to import are retrieved and assigned to their " "respective names." msgstr "" +"這裡,``spam.ham`` 模組會從 :func:`__import__` 回傳。從這個物件中,要引入的名" +"稱會被擷取並指定給它們各自的名稱。" #: ../../library/functions.rst:2295 msgid "" "If you simply want to import a module (potentially within a package) by " "name, use :func:`importlib.import_module`." msgstr "" +"如果你只想依名稱引入一個模組(可能在套件中),請使" +"用 :func:`importlib.import_module`。" #: ../../library/functions.rst:2298 msgid "" "Negative values for *level* are no longer supported (which also changes the " "default value to 0)." -msgstr "" +msgstr "不再支援 *level* 的負值(這也將預設值變為 0)。" #: ../../library/functions.rst:2302 msgid "" "When the command line options :option:`-E` or :option:`-I` are being used, " "the environment variable :envvar:`PYTHONCASEOK` is now ignored." msgstr "" +"當使用命令列選項 :option:`-E` 或 :option:`-I` 時,環境變" +"數 :envvar:`PYTHONCASEOK` 現在會被忽略。" #: ../../library/functions.rst:2307 msgid "Footnotes"