diff --git a/library/pathlib.po b/library/pathlib.po index 4db35f669b..1089de4563 100644 --- a/library/pathlib.po +++ b/library/pathlib.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Python 3.13\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-09-23 07:52+0800\n" -"PO-Revision-Date: 2024-02-29 20:49+0800\n" +"PO-Revision-Date: 2024-12-23 19:15+0800\n" "Last-Translator: Adrian Liaw \n" "Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-" "tw)\n" @@ -48,6 +48,12 @@ msgid "" "PosixPath subclasses PurePosixPath and Path, and WindowsPath\n" "subclasses PureWindowsPath and Path." msgstr "" +"顯示 pathlib 中可用類別的繼承圖。\n" +"最基礎的類別是 PurePath,它有三個直接子類別:\n" +"PurePosixPath、PureWindowsPath 和 Path。除了這四個類別之外,\n" +"還有兩個類別使用多重繼承:\n" +"PosixPath 繼承自 PurePosixPath 和 Path,而 WindowsPath 繼承自 " +"PureWindowsPath 和 Path。" #: ../../library/pathlib.rst:31 msgid "" @@ -195,6 +201,8 @@ msgid "" "An exception inheriting :exc:`NotImplementedError` that is raised when an " "unsupported operation is called on a path object." msgstr "" +"繼承自 :exc:`NotImplementedError` 的例外,當在路徑物件上呼叫不支援的操作時會" +"被引發。" #: ../../library/pathlib.rst:110 msgid "Pure paths" @@ -222,6 +230,8 @@ msgid "" ">>> PurePath('setup.py') # Running on a Unix machine\n" "PurePosixPath('setup.py')" msgstr "" +">>> PurePath('setup.py') # 執行在 Unix 機器上\n" +"PurePosixPath('setup.py')" #: ../../library/pathlib.rst:124 msgid "" @@ -609,6 +619,8 @@ msgid "" "The implementation of the :mod:`os.path` module used for low-level path " "parsing and joining: either :mod:`posixpath` or :mod:`ntpath`." msgstr "" +"用於底層路徑剖析和結合的 :mod:`os.path` 模組的實作:可能是 :mod:`posixpath` " +"或 :mod:`ntpath`。" #: ../../library/pathlib.rst:320 msgid "A string representing the drive letter or name, if any::" @@ -1015,12 +1027,16 @@ msgid "" "Windows path names that contain a colon, or end with a dot or a space, are " "considered reserved. UNC paths may be reserved." msgstr "" +"Windows 路徑名稱中包含冒號或結尾為點或空格會被視為保留。UNC 路徑可能被視為保" +"留。" #: ../../library/pathlib.rst:547 msgid "" "This method is deprecated; use :func:`os.path.isreserved` to detect reserved " "paths on Windows." msgstr "" +"此方法已被棄用;請使用 :func:`os.path.isreserved` 來檢測 Windows 上的保留路" +"徑。" #: ../../library/pathlib.rst:553 msgid "" @@ -1053,7 +1069,7 @@ msgid "" "Match this path against the provided glob-style pattern. Return ``True`` if " "matching is successful, ``False`` otherwise. For example::" msgstr "" -"將路徑與 glob 形式的樣式 (glob-style pattern) 做比對。如果比對成功則回傳 " +"將路徑與 glob 形式的模式 (glob-style pattern) 做比對。如果比對成功則回傳 " "``True``,否則回傳 ``False``,例如: ::" #: ../../library/pathlib.rst:571 @@ -1078,7 +1094,7 @@ msgstr "" #: ../../library/pathlib.rst:581 ../../library/pathlib.rst:1291 msgid ":ref:`pathlib-pattern-language` documentation." -msgstr "" +msgstr ":ref:`pathlib-pattern-language` 文件。" #: ../../library/pathlib.rst:583 msgid "As with other methods, case-sensitivity follows platform defaults::" @@ -1106,7 +1122,7 @@ msgid "" "Match this path against the provided non-recursive glob-style pattern. " "Return ``True`` if matching is successful, ``False`` otherwise." msgstr "" -"將路徑與非遞迴 glob 形式的樣式 (glob-style pattern) 做比對。如果比對成功則回" +"將路徑與非遞迴 glob 形式的模式 (glob-style pattern) 做比對。如果比對成功則回" "傳 ``True``,否則回傳 ``False``。" #: ../../library/pathlib.rst:600 @@ -1116,6 +1132,9 @@ msgid "" "\"``**``\" isn't supported (it acts like non-recursive \"``*``\"), and if a " "relative pattern is provided, then matching is done from the right::" msgstr "" +"此方法類似於 :meth:`~PurePath.full_match`,但不允許空白模式(會引發 :exc:" +"`ValueError`)、不支援遞迴萬用字元 \"``**``\"(它會像非遞迴的 \"``*``\" 一" +"樣),且如果提供相對模式,則會從右邊進行比對: ::" #: ../../library/pathlib.rst:605 msgid "" @@ -1136,7 +1155,7 @@ msgstr "" #: ../../library/pathlib.rst:612 ../../library/pathlib.rst:1310 #: ../../library/pathlib.rst:1335 msgid "The *pattern* parameter accepts a :term:`path-like object`." -msgstr "" +msgstr "*pattern* 參數接受\\ :term:`類路徑物件 `。" #: ../../library/pathlib.rst:615 ../../library/pathlib.rst:1304 #: ../../library/pathlib.rst:1329 @@ -1353,7 +1372,7 @@ msgid "" "such as from :attr:`parent` and :meth:`relative_to`. Subclasses may override " "this method to pass information to derivative paths, for example::" msgstr "" -"透過結合給定的 *pathsegments* 建立一個相同類型的新路徑物件,當一個衍生路徑被" +"透過結合給定的 *pathsegments* 建立一個相同型別的新路徑物件,當一個衍生路徑被" "建立的時候會呼叫這個方法,例如從 :attr:`parent` 和 :meth:`relative_to` 建立衍" "生路徑。子類別可以覆寫此方法來傳遞資訊給衍生路徑,例如: ::" @@ -1438,6 +1457,8 @@ msgid "" "Raises :exc:`UnsupportedOperation` on Windows. In previous versions, :exc:" "`NotImplementedError` was raised instead." msgstr "" +"在 Windows 上會引發 :exc:`UnsupportedOperation`。在先前版本中,則是引發 :exc:" +"`NotImplementedError`。" #: ../../library/pathlib.rst:785 msgid "" @@ -1460,6 +1481,8 @@ msgid "" "Raises :exc:`UnsupportedOperation` on non-Windows platforms. In previous " "versions, :exc:`NotImplementedError` was raised instead." msgstr "" +"在非 Windows 平台上會引發 :exc:`UnsupportedOperation`。在先前版本中,則是引" +"發 :exc:`NotImplementedError`。" #: ../../library/pathlib.rst:798 msgid "" @@ -1505,27 +1528,31 @@ msgid "" "Some concrete path methods can raise an :exc:`OSError` if a system call " "fails (for example because the path doesn't exist)." msgstr "" -"有些實體路徑方法會在系統呼叫失敗(例如因為路徑不存在)時引發 :exc:`OSError`" +"有些實體路徑方法會在系統呼叫失敗(例如因為路徑不存在)時引發 :exc:`OSError`。" #: ../../library/pathlib.rst:821 msgid "Parsing and generating URIs" -msgstr "" +msgstr "剖析和產生 URI" #: ../../library/pathlib.rst:823 msgid "" "Concrete path objects can be created from, and represented as, 'file' URIs " "conforming to :rfc:`8089`." msgstr "" +"實體路徑物件可以從符合 :rfc:`8089` 中的 'file' URI 建立,也可以以該形式來表" +"示。" #: ../../library/pathlib.rst:828 msgid "" "File URIs are not portable across machines with different :ref:`filesystem " "encodings `." msgstr "" +"檔案 URI 在跨不同\\ :ref:`檔案系統編碼 `\\ 的機器上是無" +"法移植的。" #: ../../library/pathlib.rst:833 msgid "Return a new path object from parsing a 'file' URI. For example::" -msgstr "" +msgstr "從剖析 'file' URI 回傳新的路徑物件。例如: ::" #: ../../library/pathlib.rst:835 msgid "" @@ -1537,7 +1564,7 @@ msgstr "" #: ../../library/pathlib.rst:838 msgid "On Windows, DOS device and UNC paths may be parsed from URIs::" -msgstr "" +msgstr "在 Windows 上,從 URI 可以剖析 DOS 裝置和 UNC 路徑: ::" #: ../../library/pathlib.rst:840 msgid "" @@ -1553,7 +1580,7 @@ msgstr "" #: ../../library/pathlib.rst:845 msgid "Several variant forms are supported::" -msgstr "" +msgstr "支援多種變形: ::" #: ../../library/pathlib.rst:847 msgid "" @@ -1566,20 +1593,29 @@ msgid "" ">>> p = Path.from_uri('file:/c|/windows')\n" "WindowsPath('c:/windows')" msgstr "" +">>> p = Path.from_uri('file:////server/share')\n" +"WindowsPath('//server/share')\n" +">>> p = Path.from_uri('file://///server/share')\n" +"WindowsPath('//server/share')\n" +">>> p = Path.from_uri('file:c:/windows')\n" +"WindowsPath('c:/windows')\n" +">>> p = Path.from_uri('file:/c|/windows')\n" +"WindowsPath('c:/windows')" #: ../../library/pathlib.rst:856 msgid "" ":exc:`ValueError` is raised if the URI does not start with ``file:``, or the " "parsed path isn't absolute." msgstr "" +"如果 URI 不是 ``file:`` 開頭,或是剖析後的路徑不是絕對路徑,則會引發 :exc:" +"`ValueError`。" #: ../../library/pathlib.rst:864 msgid "" "Represent the path as a 'file' URI. :exc:`ValueError` is raised if the path " "isn't absolute." msgstr "" -"以 ``file`` URI 來表示一個路徑。如果路徑不是絕對的則會引發 :exc:" -"`ValueError`。" +"以 'file' URI 來表示路徑。如果路徑不是絕對的則會引發 :exc:`ValueError`。" #: ../../library/pathlib.rst:867 msgid "" @@ -1602,10 +1638,12 @@ msgid "" "For historical reasons, this method is also available from :class:`PurePath` " "objects. However, its use of :func:`os.fsencode` makes it strictly impure." msgstr "" +"因為歷史上的原因,此方法也可以從 :class:`PurePath` 物件上使用。然而,它使用 :" +"func:`os.fsencode` 而讓它完全不純粹。" #: ../../library/pathlib.rst:882 msgid "Expanding and resolving paths" -msgstr "" +msgstr "擴展和解析路徑" #: ../../library/pathlib.rst:886 msgid "" @@ -1736,6 +1774,9 @@ msgid "" "strict mode, and no exception is raised in non-strict mode. In previous " "versions, :exc:`RuntimeError` is raised no matter the value of *strict*." msgstr "" +"在嚴格模式下,符號連結迴圈會像其他錯誤一樣來處理::exc:`OSError` 會被引發,而" +"在非嚴格模式下,不會引發任何例外。在先前版本中,不管 *strict* 的值是什麼,都" +"會引發 :exc:`RuntimeError`。" #: ../../library/pathlib.rst:967 msgid "" @@ -1760,10 +1801,12 @@ msgid "" "Raises :exc:`UnsupportedOperation` if :func:`os.readlink` is not available. " "In previous versions, :exc:`NotImplementedError` was raised." msgstr "" +"如果 :func:`os.readlink` 不可用,會引發 :exc:`UnsupportedOperation`。在先前版" +"本中,則是引發 :exc:`NotImplementedError`。" #: ../../library/pathlib.rst:983 msgid "Querying file type and status" -msgstr "" +msgstr "查詢檔案類型和狀態" #: ../../library/pathlib.rst:987 msgid "" @@ -2007,7 +2050,7 @@ msgstr "" #: ../../library/pathlib.rst:1164 msgid "Reading and writing files" -msgstr "" +msgstr "讀取和寫入檔案" #: ../../library/pathlib.rst:1169 msgid "" @@ -2147,7 +2190,7 @@ msgstr "" msgid "" "If the path is not a directory or otherwise inaccessible, :exc:`OSError` is " "raised." -msgstr "" +msgstr "如果路徑不是目錄或無法存取,則會引發 :exc:`OSError`。" #: ../../library/pathlib.rst:1276 msgid "" @@ -2201,6 +2244,9 @@ msgid "" "``False``, this method follows symlinks except when expanding \"``**``\" " "wildcards. Set *recurse_symlinks* to ``True`` to always follow symlinks." msgstr "" +"預設情況下,或者當 *recurse_symlinks* 僅限關鍵字引數被設定為 ``False`` 的時" +"候,此方法會跟隨符號連結,除非在擴展 \"``**``\" 萬用字元時。將 " +"*recurse_symlinks* 設成 ``True`` 以總是跟隨符號連結。" #: ../../library/pathlib.rst:1302 msgid "" @@ -2220,6 +2266,8 @@ msgid "" "suppressed. In previous versions, such exceptions are suppressed in many " "cases, but not all." msgstr "" +"從掃描檔案系統引發的任何 :exc:`OSError` 例外都會被抑制。在先前版本中,在許多" +"情況下這種例外都會被抑制,但不是所有情況。" #: ../../library/pathlib.rst:1321 msgid "" @@ -2421,10 +2469,18 @@ msgid "" " for name in dirs:\n" " (root / name).rmdir()" msgstr "" +"# 刪除可從 \"top\" 目錄到達的所有東西。\n" +"# 注意:這是危險的!例如,如果 top == Path('/'),\n" +"# 它可能會刪除你所有的檔案。\n" +"for root, dirs, files in top.walk(top_down=False):\n" +" for name in files:\n" +" (root / name).unlink()\n" +" for name in dirs:\n" +" (root / name).rmdir()" #: ../../library/pathlib.rst:1436 msgid "Creating files and directories" -msgstr "建立檔案與目錄" +msgstr "建立檔案和目錄" #: ../../library/pathlib.rst:1440 msgid "" @@ -2443,6 +2499,8 @@ msgid "" "The :meth:`~Path.open`, :meth:`~Path.write_text` and :meth:`~Path." "write_bytes` methods are often used to create files." msgstr "" +":meth:`~Path.open`、:meth:`~Path.write_text` 和 :meth:`~Path.write_bytes` 方" +"法通常用於建立檔案。" #: ../../library/pathlib.rst:1453 msgid "" @@ -2539,6 +2597,8 @@ msgid "" "Raises :exc:`UnsupportedOperation` if :func:`os.symlink` is not available. " "In previous versions, :exc:`NotImplementedError` was raised." msgstr "" +"如果 :func:`os.symlink` 不可用,會引發 :exc:`UnsupportedOperation`。在先前版" +"本中,則是引發 :exc:`NotImplementedError`。" #: ../../library/pathlib.rst:1508 msgid "Make this path a hard link to the same file as *target*." @@ -2554,10 +2614,12 @@ msgid "" "Raises :exc:`UnsupportedOperation` if :func:`os.link` is not available. In " "previous versions, :exc:`NotImplementedError` was raised." msgstr "" +"如果 :func:`os.link` 不可用,會引發 :exc:`UnsupportedOperation`。在先前版本" +"中,則是引發 :exc:`NotImplementedError`。" #: ../../library/pathlib.rst:1522 msgid "Renaming and deleting" -msgstr "" +msgstr "重新命名和刪除" #: ../../library/pathlib.rst:1526 msgid "" @@ -2652,7 +2714,7 @@ msgstr "移除此目錄。該目錄必須為空。" #: ../../library/pathlib.rst:1586 msgid "Permissions and ownership" -msgstr "" +msgstr "權限和所有權" #: ../../library/pathlib.rst:1590 msgid "" @@ -2675,6 +2737,8 @@ msgid "" "Raises :exc:`UnsupportedOperation` if the :mod:`pwd` module is not " "available. In earlier versions, :exc:`NotImplementedError` was raised." msgstr "" +"如果 :mod:`pwd` 模組不可用,會引發 :exc:`UnsupportedOperation`。在先前版本" +"中,則是引發 :exc:`NotImplementedError`。" #: ../../library/pathlib.rst:1606 msgid "" @@ -2697,6 +2761,8 @@ msgid "" "Raises :exc:`UnsupportedOperation` if the :mod:`grp` module is not " "available. In earlier versions, :exc:`NotImplementedError` was raised." msgstr "" +"如果 :mod:`grp` 模組不可用,會引發 :exc:`UnsupportedOperation`。在先前版本" +"中,則是引發 :exc:`NotImplementedError`。" #: ../../library/pathlib.rst:1622 msgid "Change the file mode and permissions, like :func:`os.chmod`." @@ -2737,37 +2803,39 @@ msgstr "" #: ../../library/pathlib.rst:1650 msgid "Pattern language" -msgstr "" +msgstr "模式語言 (pattern language)" #: ../../library/pathlib.rst:1652 msgid "" "The following wildcards are supported in patterns for :meth:`~PurePath." "full_match`, :meth:`~Path.glob` and :meth:`~Path.rglob`:" msgstr "" +"以下的萬用字元在 :meth:`~PurePath.full_match`、:meth:`~Path.glob` 和 :meth:" +"`~Path.rglob` 的模式中被支援:" #: ../../library/pathlib.rst:1655 msgid "``**`` (entire segment)" -msgstr "" +msgstr "``**``\\(整個片段)" #: ../../library/pathlib.rst:1656 msgid "Matches any number of file or directory segments, including zero." -msgstr "" +msgstr "匹配任何數量的檔案或目錄片段,包括零個。" #: ../../library/pathlib.rst:1657 msgid "``*`` (entire segment)" -msgstr "" +msgstr "``*``\\(整個片段)" #: ../../library/pathlib.rst:1658 msgid "Matches one file or directory segment." -msgstr "" +msgstr "匹配一個檔案或目錄的片段。" #: ../../library/pathlib.rst:1659 msgid "``*`` (part of a segment)" -msgstr "" +msgstr "``*``\\(片段的一部分)" #: ../../library/pathlib.rst:1660 msgid "Matches any number of non-separator characters, including zero." -msgstr "" +msgstr "匹配任意數量的非分隔字元,包括零個。" #: ../../library/pathlib.rst:1661 msgid "``?``" @@ -2775,7 +2843,7 @@ msgstr "``?``" #: ../../library/pathlib.rst:1662 msgid "Matches one non-separator character." -msgstr "" +msgstr "匹配一個非分隔字元。" #: ../../library/pathlib.rst:1663 msgid "``[seq]``" @@ -2783,7 +2851,7 @@ msgstr "``[seq]``" #: ../../library/pathlib.rst:1664 msgid "Matches one character in *seq*." -msgstr "" +msgstr "匹配一個在 *seq* 中的字元。" #: ../../library/pathlib.rst:1665 msgid "``[!seq]``" @@ -2791,21 +2859,23 @@ msgstr "``[!seq]``" #: ../../library/pathlib.rst:1666 msgid "Matches one character not in *seq*." -msgstr "" +msgstr "匹配一個不在 *seq* 中的字元。" #: ../../library/pathlib.rst:1668 msgid "" "For a literal match, wrap the meta-characters in brackets. For example, " "``\"[?]\"`` matches the character ``\"?\"``." msgstr "" +"對於文本 (literal) 匹配,可以用方括號包裝元字元 (meta-characters)。例如," +"``\"[?]\"`` 會匹配字元 ``\"?\"``。" #: ../../library/pathlib.rst:1671 msgid "The \"``**``\" wildcard enables recursive globbing. A few examples:" -msgstr "" +msgstr "\"``**``\" 萬用字元讓它可以做遞迴 glob。例如:" #: ../../library/pathlib.rst:1674 msgid "Pattern" -msgstr "" +msgstr "模式" #: ../../library/pathlib.rst:1674 msgid "Meaning" @@ -2817,7 +2887,7 @@ msgstr "\"``**/*``\"" #: ../../library/pathlib.rst:1676 msgid "Any path with at least one segment." -msgstr "" +msgstr "至少有一個片段的路徑。" #: ../../library/pathlib.rst:1677 msgid "\"``**/*.py``\"" @@ -2825,7 +2895,7 @@ msgstr "\"``**/*.py``\"" #: ../../library/pathlib.rst:1677 msgid "Any path with a final segment ending \"``.py``\"." -msgstr "" +msgstr "最後一個片段以 \"``.py``\" 結尾的任何路徑。" #: ../../library/pathlib.rst:1678 msgid "\"``assets/**``\"" @@ -2833,7 +2903,7 @@ msgstr "\"``assets/**``\"" #: ../../library/pathlib.rst:1678 msgid "Any path starting with \"``assets/``\"." -msgstr "" +msgstr "任何以 \"``assets/``\" 開頭的路徑。" #: ../../library/pathlib.rst:1679 msgid "\"``assets/**/*``\"" @@ -2842,33 +2912,39 @@ msgstr "\"``assets/**/*``\"" #: ../../library/pathlib.rst:1679 msgid "" "Any path starting with \"``assets/``\", excluding \"``assets/``\" itself." -msgstr "" +msgstr "任何以 \"``assets/``\" 開頭的路徑,不包括 \"``assets/``\" 本身。" #: ../../library/pathlib.rst:1683 msgid "" "Globbing with the \"``**``\" wildcard visits every directory in the tree. " "Large directory trees may take a long time to search." msgstr "" +"Glob 使用 ``**`` 萬用字元會訪問目錄樹中的每個目錄。對於大型的目錄樹,搜尋可能" +"需要花費很長的時間。" #: ../../library/pathlib.rst:1686 msgid "" "Globbing with a pattern that ends with \"``**``\" returns both files and " "directories. In previous versions, only directories were returned." msgstr "" +"Glob 使用結尾為 ``**`` 的模式會同時回傳檔案和目錄。在先前版本中,只會回傳目" +"錄。" #: ../../library/pathlib.rst:1690 msgid "" "In :meth:`Path.glob` and :meth:`~Path.rglob`, a trailing slash may be added " "to the pattern to match only directories." msgstr "" +"在 :meth:`Path.glob` 和 :meth:`~Path.rglob` 中,可以在模式後面加上斜線以只匹" +"配目錄。" #: ../../library/pathlib.rst:1693 msgid "" "Globbing with a pattern that ends with a pathname components separator (:" "data:`~os.sep` or :data:`~os.altsep`) returns only directories." msgstr "" -"如果 *pattern* 以路徑名稱組成的分隔符號(:data:`~os.sep` 或 :data:`~os." -"altsep`)作結尾來 glob 則只會回傳目錄。" +"Glob 使用以路徑名稱組成的分隔符號(:data:`~os.sep` 或 :data:`~os.altsep`)作" +"結尾的模式則只會回傳目錄。" #: ../../library/pathlib.rst:1699 msgid "Comparison to the :mod:`glob` module" @@ -2879,18 +2955,24 @@ msgid "" "The patterns accepted and results generated by :meth:`Path.glob` and :meth:" "`Path.rglob` differ slightly from those by the :mod:`glob` module:" msgstr "" +":meth:`Path.glob` 和 :meth:`Path.rglob` 接受的模式和產生的結果與 :mod:`glob` " +"模組略有不同:" #: ../../library/pathlib.rst:1704 msgid "" "Files beginning with a dot are not special in pathlib. This is like passing " "``include_hidden=True`` to :func:`glob.glob`." msgstr "" +"pathlib 中以點開頭的檔案並不特別。這和將 ``include_hidden=True`` 傳遞給 :" +"func:`glob.glob` 相同。" #: ../../library/pathlib.rst:1706 msgid "" "\"``**``\" pattern components are always recursive in pathlib. This is like " "passing ``recursive=True`` to :func:`glob.glob`." msgstr "" +"``**`` 模式組成在 pathlib 中總是遞迴的。這與將 ``recursive=True`` 傳遞給 :" +"func:`glob.glob` 相同。" #: ../../library/pathlib.rst:1708 msgid "" @@ -2898,12 +2980,17 @@ msgid "" "This behaviour has no equivalent in :func:`glob.glob`, but you can pass " "``recurse_symlinks=True`` to :meth:`Path.glob` for compatible behaviour." msgstr "" +"在 pathlib 中,``**`` 模式組成預設不跟隨符號連結。這在 :func:`glob.glob` 中沒" +"有等效的行為,但你可以將 ``recurse_symlinks=True`` 傳遞給 :meth:`Path.glob` " +"以獲得相容的行為。" #: ../../library/pathlib.rst:1711 msgid "" "Like all :class:`PurePath` and :class:`Path` objects, the values returned " "from :meth:`Path.glob` and :meth:`Path.rglob` don't include trailing slashes." msgstr "" +"與所有 :class:`PurePath` 和 :class:`Path` 物件一樣,從 :meth:`Path.glob` 和 :" +"meth:`Path.rglob` 回傳的值不包含結尾斜線。" #: ../../library/pathlib.rst:1714 msgid "" @@ -2911,6 +2998,8 @@ msgid "" "include the *path* as a prefix, unlike the results of ``glob." "glob(root_dir=path)``." msgstr "" +"pathlib 的 ``path.glob()`` 和 ``path.rglob()`` 回傳的值包含了 *path* 作為前" +"綴,而 ``glob.glob(root_dir=path)`` 的結果則不會如此。" #: ../../library/pathlib.rst:1717 msgid "" @@ -2919,6 +3008,9 @@ msgid "" "results of ``glob.glob(root_dir=path)`` never include an empty string that " "would correspond to *path*." msgstr "" +"pathlib 的 ``path.glob()`` 和 ``path.rglob()`` 回傳的值可能包含 *path* 本身," +"例如當使用 \"``**``\" 做 glob 的時候,然而 ``glob.glob(root_dir=path)`` 的結" +"果則永遠不會包含一個對應到 *path* 的空字串。" #: ../../library/pathlib.rst:1724 msgid "Comparison to the :mod:`os` and :mod:`os.path` modules" @@ -2932,6 +3024,10 @@ msgid "" "level ``str`` and ``bytes`` objects, which is a more *procedural* approach. " "Some users consider the object-oriented style to be more readable." msgstr "" +"pathlib 使用 :class:`PurePath` 和 :class:`Path` 物件來實作路徑操作,因此它被" +"稱為是\\ *物件導向*\\ 的。另一方面,:mod:`os` 和 :mod:`os.path` 模組提供能夠" +"與底層 ``str`` 和 ``bytes`` 物件互動的函式,這是一種更\\ *程序式*\\ 的方法。" +"有些使用者認為物件導向的風格更易讀。" #: ../../library/pathlib.rst:1732 msgid "" @@ -2939,6 +3035,9 @@ msgid "" "ref:`paths relative to directory descriptors `. These features " "aren't available in pathlib." msgstr "" +":mod:`os` 和 :mod:`os.path` 中的許多函式支援 ``bytes`` 路徑和\\ :ref:`相對路" +"徑的目錄描述器 (paths relative to directory descriptors) `。這些功能" +"在 pathlib 中不可用。" #: ../../library/pathlib.rst:1736 msgid "" @@ -2946,6 +3045,9 @@ msgid "" "`os.path` modules, are written in C and are very speedy. pathlib is written " "in pure Python and is often slower, but rarely slow enough to matter." msgstr "" +"Python 的 ``str`` 和 ``bytes`` 型別,以及 :mod:`os` 和 :mod:`os.path` 模組的" +"一些部分,是用 C 寫的且非常快速。pathlib 是用純 Python 寫的且通常比較慢,但很" +"少會慢到足以產生影響。" #: ../../library/pathlib.rst:1740 msgid "" @@ -2955,11 +3057,14 @@ msgid "" "are involved, :meth:`Path.absolute` preserves these segments for greater " "safety." msgstr "" +"pathlib 的路徑正規化略比 :mod:`os.path` 更武斷和一致。例如,儘管 :func:`os." +"path.abspath` 會從路徑中移除 \"``..``\" 片段,如果包含符號連結的話這可能會改" +"變其意義,而 :meth:`Path.absolute` 則會保留這些片段以增加安全性。" #: ../../library/pathlib.rst:1745 msgid "" "pathlib's path normalization may render it unsuitable for some applications:" -msgstr "" +msgstr "pathlib 的路徑正規化可能會使它不適合某些應用程式:" #: ../../library/pathlib.rst:1747 msgid "" @@ -2969,6 +3074,9 @@ msgid "" "separator may allow the path to be resolved as either a file or directory, " "rather than a directory only." msgstr "" +"pathlib 將 ``Path(\"my_folder/\")`` 正規化為 ``Path(\"my_folder\")``,這會在" +"提供給各種操作系統 API 和命令列工具時改變路徑的意義。具體來說,缺少結尾分隔符" +"號可能會允許該路徑被解析為檔案或目錄,而不只是目錄。" #: ../../library/pathlib.rst:1752 msgid "" @@ -2978,16 +3086,20 @@ msgid "" "a separator in the path may force it to be looked up in :envvar:`PATH` " "rather than the current directory." msgstr "" +"pathlib 將 ``Path(\"./my_program\")`` 正規化為 ``Path(\"my_program\")``,這會" +"在作為執行檔搜尋路徑使用時改變路徑的意義,例如在 shell 或在衍生 (spawn) 子行" +"程時。具體來說,在路徑中缺少分隔符號可能會使其強制在 :envvar:`PATH` 中尋找," +"而不是當前目錄。" #: ../../library/pathlib.rst:1758 msgid "" "As a consequence of these differences, pathlib is not a drop-in replacement " "for :mod:`os.path`." -msgstr "" +msgstr "因為這些差異,pathlib 不是 :mod:`os.path` 的直接替代品。" #: ../../library/pathlib.rst:1763 msgid "Corresponding tools" -msgstr "" +msgstr "對應工具" #: ../../library/pathlib.rst:1765 msgid "" @@ -3255,7 +3367,7 @@ msgstr ":meth:`Path.lchmod`" #: ../../library/pathlib.rst:1805 msgid "Footnotes" -msgstr "註解" +msgstr "註腳" #: ../../library/pathlib.rst:1806 msgid "" @@ -3264,6 +3376,10 @@ msgid "" "is a lexical operation that raises :exc:`ValueError` when its inputs' " "anchors differ (e.g. if one path is absolute and the other relative.)" msgstr "" +":func:`os.path.relpath` 會呼叫 :func:`~os.path.abspath` 來將路徑變成絕對路徑" +"並移除 \"``..``\" 部分,而 :meth:`PurePath.relative_to` 是一個文本上的操作," +"當它輸入的錨點不同時(例如一個是絕對路徑,另一個則是相對路徑)會引發 :exc:" +"`ValueError`。" #: ../../library/pathlib.rst:1810 msgid "" @@ -3271,6 +3387,8 @@ msgid "" "can't be resolved, whereas :meth:`Path.expanduser` raises :exc:" "`RuntimeError`." msgstr "" +":func:`os.path.expanduser` 會在無法解析家目錄時回傳原始路徑,而 :meth:`Path." +"expanduser` 則會引發 :exc:`RuntimeError`。" #: ../../library/pathlib.rst:1813 msgid "" @@ -3278,6 +3396,8 @@ msgid "" "symlinks, which may change the meaning of the path, whereas :meth:`Path." "absolute` leaves any \"``..``\" components in the path." msgstr "" +":func:`os.path.abspath` 將 \"``..``\" 組成移除而不解析符號連結,這可能會改變" +"路徑的意義,而 :meth:`Path.absolute` 則會保留路徑中任何 \"``..``\" 組成。" #: ../../library/pathlib.rst:1816 msgid "" @@ -3285,6 +3405,9 @@ msgid "" "*dirnames* and *filenames*, whereas :meth:`Path.walk` categorizes all " "symlinks into *filenames* when *follow_symlinks* is false (the default.)" msgstr "" +"當分類路徑成 *dirnames* 和 *filenames* 時 :func:`os.walk` 總是跟隨符號連結," +"而 :meth:`Path.walk` 在 *follow_symlinks* 為 false(預設值)時,會將所有符號" +"連結都分類為 *filenames*。" #: ../../library/pathlib.rst:11 msgid "path" @@ -3293,99 +3416,3 @@ msgstr "path(路徑)" #: ../../library/pathlib.rst:11 msgid "operations" msgstr "operations(操作)" - -#~ msgid "" -#~ "File system calls on reserved paths can fail mysteriously or have " -#~ "unintended effects." -#~ msgstr "在保留路徑上的檔案系統呼叫會神秘地失敗或有意外的效果。" - -#~ msgid "" -#~ "If *pattern* is relative, the path can be either relative or absolute, " -#~ "and matching is done from the right::" -#~ msgstr "" -#~ "如果 *pattern* 是相對的,則路徑可以是相對或絕對的,而且會從右邊來完成比" -#~ "對: ::" - -#~ msgid "" -#~ "If *pattern* is absolute, the path must be absolute, and the whole path " -#~ "must match::" -#~ msgstr "" -#~ "如果 *pattern* 是絕對的,則路徑必須是絕對的,且整個路徑都要比對到: ::" - -#~ msgid "" -#~ ">>> PurePath('/a.py').match('/*.py')\n" -#~ "True\n" -#~ ">>> PurePath('a/b.py').match('/*.py')\n" -#~ "False" -#~ msgstr "" -#~ ">>> PurePath('/a.py').match('/*.py')\n" -#~ "True\n" -#~ ">>> PurePath('a/b.py').match('/*.py')\n" -#~ "False" - -#~ msgid "" -#~ "The *pattern* may be another path object; this speeds up matching the " -#~ "same pattern against multiple files::" -#~ msgstr "" -#~ "*pattern* 可以是另一個路徑物件;這會加速對多個檔案比對相同的樣式: ::" - -#~ msgid "" -#~ ">>> pattern = PurePath('*.py')\n" -#~ ">>> PurePath('a/b.py').match(pattern)\n" -#~ "True" -#~ msgstr "" -#~ ">>> pattern = PurePath('*.py')\n" -#~ ">>> PurePath('a/b.py').match(pattern)\n" -#~ "True" - -#~ msgid "Accepts an object implementing the :class:`os.PathLike` interface." -#~ msgstr "接受一個有實作 :class:`os.PathLike` 介面的物件。" - -#~ msgid "" -#~ ">>> sorted(Path('.').glob('*.py'))\n" -#~ "[PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib." -#~ "py')]\n" -#~ ">>> sorted(Path('.').glob('*/*.py'))\n" -#~ "[PosixPath('docs/conf.py')]" -#~ msgstr "" -#~ ">>> sorted(Path('.').glob('*.py'))\n" -#~ "[PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib." -#~ "py')]\n" -#~ ">>> sorted(Path('.').glob('*/*.py'))\n" -#~ "[PosixPath('docs/conf.py')]" - -#~ msgid "" -#~ "Patterns are the same as for :mod:`fnmatch`, with the addition of " -#~ "\"``**``\" which means \"this directory and all subdirectories, " -#~ "recursively\". In other words, it enables recursive globbing::" -#~ msgstr "" -#~ "模式 (pattern) 和給 :mod:`fnmatch` 的一樣,加上 \"``**``\" 代表「目前目錄" -#~ "及所有遞迴的子目錄」。也就是說它能夠做遞迴的 glob 比對: ::" - -#~ msgid "" -#~ "This method calls :meth:`Path.is_dir` on the top-level directory and " -#~ "propagates any :exc:`OSError` exception that is raised. Subsequent :exc:" -#~ "`OSError` exceptions from scanning directories are suppressed." -#~ msgstr "" -#~ "此方法在頂層目錄上呼叫 :meth:`Path.is_dir` 並傳遞引發的任何 :exc:" -#~ "`OSError` 例外。將會抑制在目錄對於 :exc:`OSError` 例外的後續掃描。" - -#~ msgid "" -#~ "Using the \"``**``\" pattern in large directory trees may consume an " -#~ "inordinate amount of time." -#~ msgstr "在很大的目錄樹裡使用 \"``**``\" 可能會耗費過多的時間。" - -#~ msgid "" -#~ ">>> sorted(Path().rglob(\"*.py\"))\n" -#~ "[PosixPath('build/lib/pathlib.py'),\n" -#~ " PosixPath('docs/conf.py'),\n" -#~ " PosixPath('pathlib.py'),\n" -#~ " PosixPath('setup.py'),\n" -#~ " PosixPath('test_pathlib.py')]" -#~ msgstr "" -#~ ">>> sorted(Path().rglob(\"*.py\"))\n" -#~ "[PosixPath('build/lib/pathlib.py'),\n" -#~ " PosixPath('docs/conf.py'),\n" -#~ " PosixPath('pathlib.py'),\n" -#~ " PosixPath('setup.py'),\n" -#~ " PosixPath('test_pathlib.py')]" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy