@@ -48,8 +48,8 @@ msgid ""
48
48
"ref:`tut-modules` for an introduction."
49
49
msgstr ""
50
50
"這兩種機制都與 Python 模組有關;使用者如何與它們互動以及它們如何彼此互動。下"
51
- "面會詳細解釋它們。如果你不熟悉 Python 模組,請參閱教學章節 :ref:`tut-modules` "
52
- "的介紹。"
51
+ "面會詳細解釋它們。如果你不熟悉 Python 模組,請參閱教學章節 :ref:`tut-"
52
+ "modules` 的介紹。"
53
53
54
54
#: ../../library/__main__.rst:25
55
55
msgid "``__name__ == '__main__'``"
@@ -92,9 +92,9 @@ msgid ""
92
92
"program needs. Sometimes \" top-level code\" is called an *entry point* to "
93
93
"the application."
94
94
msgstr ""
95
- "``__main__`` 是執行頂層程式碼的環境名稱。「頂層程式碼」是使用者指定且第一 "
96
- "個開始運作的 Python 模組。它是「頂層」的原因是因為它引入程式所需的所有其他模 "
97
- "組。 有時「頂層程式碼」被稱為應用程式的\\ *入口點*。"
95
+ "``__main__`` 是執行頂層程式碼的環境名稱。「頂層程式碼」是使用者指定且第一個開 "
96
+ "始運作的 Python 模組。它是「頂層」的原因是因為它引入程式所需的所有其他模組。 "
97
+ "有時「頂層程式碼」被稱為應用程式的\\ *入口點*。"
98
98
99
99
#: ../../library/__main__.rst:53
100
100
msgid "The top-level code environment can be:"
@@ -179,8 +179,8 @@ msgid ""
179
179
"function named ``main`` encapsulates the program's primary behavior::"
180
180
msgstr ""
181
181
"在 ``if __name__ == '__main__'`` 下面的區塊中放置盡可能少的陳述式可以提高程式"
182
- "碼的清晰度和正確性。大多數情況下,名為 ``main`` 的函式封裝 (encapsulate) 了程式 "
183
- "的主要行為 : ::"
182
+ "碼的清晰度和正確性。大多數情況下,名為 ``main`` 的函式封裝 (encapsulate) 了程 "
183
+ "式的主要行為 : ::"
184
184
185
185
#: ../../library/__main__.rst:151
186
186
msgid ""
@@ -219,8 +219,8 @@ msgid ""
219
219
"return value of ``main`` is passed into :func:`sys.exit`. For example::"
220
220
msgstr ""
221
221
"``main`` 函式通常用於透過將它們指定為控制台腳本的入口點來建立命令列工具。完成"
222
- "後,`pip <https://pip.pypa.io/>`_ 將函式呼叫插入到模板腳本中,其中 "
223
- "``main`` 的回傳值被傳遞到 :func:`sys.exit` 中。例如: ::"
222
+ "後,`pip <https://pip.pypa.io/>`_ 將函式呼叫插入到模板腳本中,其中 ``main`` "
223
+ "的回傳值被傳遞到 :func:`sys.exit` 中。例如: ::"
224
224
225
225
#: ../../library/__main__.rst:175
226
226
msgid ""
@@ -230,8 +230,8 @@ msgid ""
230
230
"if your function does not have a return statement)."
231
231
msgstr ""
232
232
"由於對 ``main`` 的呼叫包含在 :func:`sys.exit` 中,因此期望你的函式將傳回一些"
233
- "可接受作為 :func:`sys.exit` 輸入的值;通常來說,會是一個整數或 "
234
- "``None`` \\ (如果你的函式沒有 return 陳述式,則相當於回傳此值)。"
233
+ "可接受作為 :func:`sys.exit` 輸入的值;通常來說,會是一個整數或 ``None`` \\ (如 "
234
+ "果你的函式沒有 return 陳述式,則相當於回傳此值)。"
235
235
236
236
#: ../../library/__main__.rst:180
237
237
msgid ""
@@ -252,9 +252,9 @@ msgid ""
252
252
"py`` example from earlier exemplifies using the ``sys.exit(main())`` "
253
253
"convention."
254
254
msgstr ""
255
- "特別是,要謹慎處理從 ``main`` 函式回傳字串。:func:`sys.exit` 會將字串引數直 "
256
- "譯為失敗訊息 ,因此你的程式將有一個表示失敗的結束代碼 ``1``,並且該字串將被 "
257
- "寫入 :data:`sys.stderr`。前面的 ``echo.py`` 範例使用慣例的 ``sys."
255
+ "特別是,要謹慎處理從 ``main`` 函式回傳字串。:func:`sys.exit` 會將字串引數直譯 "
256
+ "為失敗訊息 ,因此你的程式將有一個表示失敗的結束代碼 ``1``,並且該字串將被寫 "
257
+ "入 :data:`sys.stderr`。前面的 ``echo.py`` 範例使用慣例的 ``sys."
258
258
"exit(main())`` 進行示範。"
259
259
260
260
#: ../../library/__main__.rst:193
@@ -263,8 +263,8 @@ msgid ""
263
263
"collection of tutorials and references on how to distribute and install "
264
264
"Python packages with modern tools."
265
265
msgstr ""
266
- "`Python 打包使用者指南 <https://packaging.python.org/>`_\\ 包含一系列如何使 "
267
- "用現代工具發行和安裝 Python 套件的教學和參考資料。"
266
+ "`Python 打包使用者指南 <https://packaging.python.org/>`_\\ 包含一系列如何使用 "
267
+ "現代工具發行和安裝 Python 套件的教學和參考資料。"
268
268
269
269
#: ../../library/__main__.rst:199
270
270
msgid "``__main__.py`` in Python Packages"
@@ -307,8 +307,8 @@ msgid ""
307
307
"the :ref:`tut-modules` section of the tutorial."
308
308
msgstr ""
309
309
"請注意,``from .student import search_students`` 是相對引入的範例。在引用套件"
310
- "內的模組時,可以使用此引入樣式。有關更多詳細資訊,請參閱 :ref:`tut-"
311
- "modules` 教學章節中的 :ref:`intra-package-references`。"
310
+ "內的模組時,可以使用此引入樣式。有關更多詳細資訊,請參閱 :ref:`tut-modules` "
311
+ "教學章節中的 :ref:`intra-package-references`。"
312
312
313
313
#: ../../library/__main__.rst:241
314
314
msgid ""
@@ -327,8 +327,9 @@ msgid ""
327
327
"for a ``__main__.py`` file within a package, because its ``__name__`` "
328
328
"attribute will include the package's path if imported::"
329
329
msgstr ""
330
- "如果在套件裡面的 ``__main__.py`` 檔案使用 ``if __name__ == '__main__'`` 區塊,"
331
- "它依然會如預期般地運作。因為當引入套件,其 ``__name__`` 屬性將會包含套件的路徑: ::"
330
+ "如果在套件裡面的 ``__main__.py`` 檔案使用 ``if __name__ == '__main__'`` 區"
331
+ "塊,它依然會如預期般地運作。因為當引入套件,其 ``__name__`` 屬性將會包含套件"
332
+ "的路徑: ::"
332
333
333
334
#: ../../library/__main__.rst:254
334
335
msgid ""
@@ -345,8 +346,8 @@ msgid ""
345
346
"in the standard library. It doesn't contain a ``if __name__ == '__main__'`` "
346
347
"block. You can invoke it with ``python -m venv [directory]``."
347
348
msgstr ""
348
- "請參閱 :mod:`venv` 作為標準函式庫中具有最小 ``__main__.py`` 的套件為範例。它不 "
349
- "包含 ``if __name__ == '__main__'`` 區塊。你可以使用 ``python -m venv "
349
+ "請參閱 :mod:`venv` 作為標準函式庫中具有最小 ``__main__.py`` 的套件為範例。它 "
350
+ "不包含 ``if __name__ == '__main__'`` 區塊。你可以使用 ``python -m venv "
350
351
"[directory]`` 來呼叫它。"
351
352
352
353
#: ../../library/__main__.rst:264
@@ -400,8 +401,8 @@ msgid ""
400
401
"the line with ``my_name = \" Dinsdale\" `` fixes the program and now it exits "
401
402
"with status code 0, indicating success:"
402
403
msgstr ""
403
- "程式的結束代碼將為 1,表示出現錯誤。取消註解 ``my_name = \" Dinsdale\" `` 而 "
404
- "修復程式後 ,現在它以狀態碼 0 結束,表示成功:"
404
+ "程式的結束代碼將為 1,表示出現錯誤。取消註解 ``my_name = \" Dinsdale\" `` 而修 "
405
+ "復程式後 ,現在它以狀態碼 0 結束,表示成功:"
405
406
406
407
#: ../../library/__main__.rst:335
407
408
msgid ""
@@ -410,9 +411,9 @@ msgid ""
410
411
"the ``if __name__ == \" __main__\" `` block of the ``start`` module. Why does "
411
412
"this work?"
412
413
msgstr ""
413
- "請注意,引入 ``__main__`` 並不會因為不經意地執行放在 ``start`` 模組中 "
414
- "``if __name__ == \" __main__\" `` 區塊的頂層程式碼(本來是給腳本使用的)而造成任何問題 "
415
- "。為什麼這樣做會如預期運作?"
414
+ "請注意,引入 ``__main__`` 並不會因為不經意地執行放在 ``start`` 模組中 ``if "
415
+ "__name__ == \" __main__\" `` 區塊的頂層程式碼(本來是給腳本使用的)而造成任何問 "
416
+ "題 。為什麼這樣做會如預期運作?"
416
417
417
418
#: ../../library/__main__.rst:339
418
419
msgid ""
@@ -426,21 +427,21 @@ msgid ""
426
427
"<import-dunder-main>` in the import system's reference for details on how "
427
428
"this works."
428
429
msgstr ""
429
- "當 Python 直譯器啟動時,會在 :data:`sys.modules` 中插入一個空的 ``__main__`` 模 "
430
- "組 ,並透過執行頂層程式碼來填充它。在我們的範例中,這是 ``start`` 模組,它將逐 "
431
- "行執行並引入 ``namely``。接著,``namely`` 引入 ``__main__``\\ (其實是 "
430
+ "當 Python 直譯器啟動時,會在 :data:`sys.modules` 中插入一個空的 ``__main__`` "
431
+ "模組 ,並透過執行頂層程式碼來填充它。在我們的範例中,這是 ``start`` 模組,它將 "
432
+ "逐行執行並引入 ``namely``。接著,``namely`` 引入 ``__main__``\\ (其實是 "
432
433
"``start``)。這就是一個引入循環!幸運的是,由於部分填充的 ``__main__`` 模組存"
433
434
"在於 :data:`sys.modules` 中,Python 將其傳遞給 ``namely``。請參閱引入系統參考"
434
- "文件中的\\ :ref:`關於 __main__ 的特別考量 <import-dunder-main>`\\ 了解其工作原理 "
435
- "的詳細資訊 。"
435
+ "文件中的\\ :ref:`關於 __main__ 的特別考量 <import-dunder-main>`\\ 了解其工作 "
436
+ "原理的詳細資訊 。"
436
437
437
438
#: ../../library/__main__.rst:348
438
439
msgid ""
439
440
"The Python REPL is another example of a \" top-level environment\" , so "
440
441
"anything defined in the REPL becomes part of the ``__main__`` scope::"
441
442
msgstr ""
442
- "Python REPL 是「頂層環境」的另一個範例,因此 REPL 中定義的任何內容都成為 "
443
- "作域的一部分 : ::"
443
+ "Python REPL 是「頂層環境」的另一個範例,因此 REPL 中定義的任何內容都成為 作域 "
444
+ "的一部分 : ::"
444
445
445
446
#: ../../library/__main__.rst:364
446
447
msgid ""
0 commit comments