|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <title>Python 3.9</title> |
| 5 | + <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> |
| 6 | + <style> |
| 7 | + |
| 8 | + |
| 9 | +/* |
| 10 | +Based on Minimal CSS (minimalcss.com) under the MIT license. |
| 11 | +*/ |
| 12 | + |
| 13 | +/* Reset */ |
| 14 | +* { margin: 0; padding: 0; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } |
| 15 | + |
| 16 | +/* Layout */ |
| 17 | +body { background-color: #fff; color: #333; font: 14px/20px -apple-system, "HelveticaNeue", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; } |
| 18 | + |
| 19 | +header { width: 100%; margin: 0 auto; position: relative; padding: 20px 0; margin-bottom: 20px; } |
| 20 | + |
| 21 | +nav ul { margin: 0; } |
| 22 | +nav ul li { display: inline; margin-right: 20px; font-size: 16px; line-height: 28px; color: #333; } |
| 23 | +nav ul li a { color: #333; } |
<
67E6
/code> | 24 | + |
| 25 | +.container { position: relative; max-width: 90%; margin: 0 auto; } |
| 26 | + |
| 27 | +footer { border-top:1px solid #ccc; font-size:11px; line-height:26px; color:#999; } |
| 28 | +footer a { color:#999999; } |
| 29 | +footer a:hover { color:#105CB6; } |
| 30 | +footer ul li { display:inline; list-style:none; padding-left:20px; } |
| 31 | + |
| 32 | +/* Typography */ |
| 33 | +a { color: #105CB6; text-decoration: none; } |
| 34 | +a:hover, a:focus { color: #105CB6; text-decoration: underline; } |
| 35 | +a:active { color: #105CB6; } |
| 36 | + |
| 37 | +h1 { font-size: 24px; line-height: 20px; margin: 10px 0; } |
| 38 | +h2 { font-size: 20px; line-height: 20px; margin: 10px 0; } |
| 39 | +h3 { font-size: 16px; line-height: 20px; margin: 10px 0; } |
| 40 | +h4 { font-size: 14px; line-height: 20px; margin: 10px 0; } |
| 41 | +h5 { font-size: 12px; line-height: 20px; margin: 10px 0; } |
| 42 | +h5 { font-size: 10px; line-height: 20px; margin: 10px 0; } |
| 43 | +h1,h2,h3,h4,h5,h6 { color: #333; } |
| 44 | + |
| 45 | +p { margin-bottom: 10px; } |
| 46 | + |
| 47 | +.float-left { float: left; } |
| 48 | +.float-right { float: right; } |
| 49 | +img.float-left { float: left; margin: 0 20px 20px 0; } |
| 50 | +img.float-right { float: right; margin: 0 0 20px 20px; } |
| 51 | +img.center { margin: 0 auto; display: block; } |
| 52 | + |
| 53 | +.text-left { text-align: left; } |
| 54 | +.text-center { text-align: center; } |
| 55 | +.text-right { text-align: right; } |
| 56 | +.text-justify { text-align: justify; } |
| 57 | + |
| 58 | +/* Misc */ |
| 59 | +hr { background-color: #ccc; border: 0px; color: #ccc; height: 1px; margin: 8px 0 20px 0; } |
| 60 | +pre, code { background:#E0ECF6; display:block; margin-bottom: 20px; padding:10px; } |
| 61 | + |
| 62 | +blockquote { margin: 10px 10px 20px; padding: 9px; background-color: #f8f8f8; color: #666; border-left: 5px solid #ddd; font: 14px/20px Georgia, Times, serif; quotes: "\201C" "\201D"; } |
| 63 | +blockquote p { margin: 0; } |
| 64 | +blockquote:before { content: open-quote; font-weight: bold; } |
| 65 | +blockquote:after { content: close-quote; font-weight: bold; } |
| 66 | + |
| 67 | +/* List */ |
| 68 | +ul { list-style-position:inside; } |
| 69 | +ol { list-style-position:inside; } |
| 70 | + |
| 71 | +/* Table */ |
| 72 | +table { |
| 73 | + border-collapse: collapse; |
| 74 | + border-spacing: 0; |
| 75 | +} |
| 76 | +th { font-weight: bold; } |
| 77 | +tfoot { font-style: italic; } |
| 78 | + |
| 79 | +/* Metadata part */ |
| 80 | + |
| 81 | +.metadata { |
| 82 | + margin-top: 15px; |
| 83 | + margin-bottom: 10px; |
| 84 | + font-size: 90%; |
| 85 | +} |
| 86 | +table.metadata td { |
| 87 | + padding-right: 20px; |
| 88 | +} |
| 89 | + |
| 90 | +.stats { |
| 91 | + padding-top: 5px; |
| 92 | + padding-bottom: 20px; |
| 93 | +} |
| 94 | +.graph { |
| 95 | + width: 100%; |
| 96 | +} |
| 97 | +.graph div { float: left; } |
| 98 | +.graph div:first-child { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } |
| 99 | +.graph div:last-child { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } |
| 100 | +.percent-done { background-color: rgb(90, 228, 140); height: 10px; } |
| 101 | +.percent-fuzzy { background-color: rgb(255, 167, 52); height: 10px; } |
| 102 | +.percent-untrans { background-color: #F1F1F1; height: 10px; } |
| 103 | +.legend { |
| 104 | + font-size: smaller; |
| 105 | + color: #aaa; |
| 106 | + padding-top: 12px; |
| 107 | + text-align: center; |
| 108 | +} |
| 109 | + |
| 110 | +/* Translations */ |
| 111 | +table.translations { |
| 112 | + width: 100%; |
| 113 | + table-layout: fixed; |
| 114 | +} |
| 115 | +table.translations th, table.translations td { |
| 116 | + padding: 5px 10px; |
| 117 | + vertical-align: top; |
| 118 | + border-bottom: 1px solid #E1E1E1; |
| 119 | +} |
| 120 | +table.translations th { |
| 121 | + text-align: left; |
| 122 | +} |
| 123 | +table.translations th:first-child, table.translations td:first-child { padding-left: 0; } |
| 124 | +table.translations th:last-child, table.translations td:last-child { padding-right: 0; } |
| 125 | + |
| 126 | +.with-comments td { |
| 127 | + border-bottom: none !important; |
| 128 | +} |
| 129 | +tr.comments div { |
| 130 | + float: left; |
| 131 | + max-width: 90%; |
| 132 | + font-size: smaller; |
| 133 | + color: #aaa; |
| 134 | +} |
| 135 | +tr.comments div p:last-child { margin-bottom: 0; } |
| 136 | +tr.comments td { padding-top: 0; } |
| 137 | + |
| 138 | +.fuzzy .tra { |
| 139 | + color: rgb(218, 123, 0); |
| 140 | +} |
| 141 | + |
| 142 | +.msgctxt { |
| 143 | + color: rgb(70, 109, 137); |
| 144 | + font-size: smaller; |
| 145 | + background-color: rgb(217, 232, 242); |
| 146 | + border-radius: 2px; |
| 147 | + padding: 2px 4px; |
| 148 | + margin-right: 4px; |
| 149 | +} |
| 150 | + |
| 151 | + |
| 152 | + </style> |
| 153 | +</head> |
| 154 | +<body> |
| 155 | +<div class='container'> |
| 156 | +<table class='metadata'> |
| 157 | +<tr><td>專案:</td><td>Python 3.9</td></tr> |
| 158 | +<tr><td>語言:</td><td>中文(台灣)</td></tr> |
| 159 | +</table> |
| 160 | +<div class='stats'> |
| 161 | + <div class='graph'> |
| 162 | + <div class='percent-done' style='width: 100%'> </div> |
| 163 | + </div> |
| 164 | + <div class='legend'>已翻譯 27 筆,總計 27 筆 (完成度為 100%) </div> |
| 165 | +</div> |
| 166 | +<table class='translations'> |
| 167 | + <thead> |
| 168 | + <tr> |
| 169 | + <th>原文 — 英文</th> |
| 170 | + <th>譯文 — 中文(台灣)</th> |
| 171 | + </tr> |
| 172 | + </thead> |
| 173 | + <tbody> |
| 174 | +<tr class='i'> |
| 175 | +<td class='src' lang='en'> |
| 176 | +Using the Python Interpreter</td> |
| 177 | +<td class='tra' lang='zh-TW'> |
| 178 | +使用 Python 直譯器</td> |
| 179 | +</tr> |
| 180 | +<tr class='i'> |
| 181 | +<td class='src' lang='en'> |
| 182 | +Invoking the Interpreter</td> |
| 183 | +<td class='tra' lang='zh-TW'> |
| 184 | +啟動直譯器</td> |
| 185 | +</tr> |
| 186 | +<tr class='i'> |
| 187 | +<td class='src' lang='en'> |
| 188 | +The Python interpreter is usually installed as :file:`/usr/local/bin/python3.9` on those machines where it is available; putting :file:`/usr/local/bin` in your Unix shell's search path makes it possible to start it by typing the command:</td> |
| 189 | +<td class='tra' lang='zh-TW'> |
| 190 | +Python解釋器一般安裝在 :file:`/usr/local/bin/python3.9`路徑下;將:file:`/usr/local/bin`加入Unix終端的搜索路徑,鍵入以下命令就可以啟動Python:</td> |
| 191 | +</tr> |
| 192 | +<tr class='i'> |
| 193 | +<td class='src' lang='en'> |
| 194 | +to the shell. [#]_ Since the choice of the directory where the interpreter lives is an installation option, other places are possible; check with your local Python guru or system administrator. (E.g., :file:`/usr/local/python` is a popular alternative location.)</td> |
| 195 | +<td class='tra' lang='zh-TW'> |
| 196 | +能啟動 Python [#]_\ 。因為直譯器存放的目錄是個安裝選項,其他的目錄也是有可能的;請洽談在地的 Python 達人或者系統管理員。(例如:\ :file:`/usr/local/python` 是個很常見的另類存放路徑。)</td> |
| 197 | +</tr> |
| 198 | +<tr class='i'> |
| 199 | +<td class='src' lang='en'> |
| 200 | +On Windows machines where you have installed Python from the :ref:`Microsoft Store <windows-store>`, the :file:`python3.9` command will be available. If you have the :ref:`py.exe launcher <launcher>` installed, you can use the :file:`py` command. See :ref:`setting-envvars` for other ways to launch Pyth
67DE
on.</td> |
| 201 | +<td class='tra' lang='zh-TW'> |
| 202 | +Windows系統中,從:ref:`Microsoft Store <windows-store>`安裝Python後,就可以使用:file:`python3.9` 命令了。如果安裝了:ref:`py.exe launcher <launcher>`,則可以使用:file:`py`命令。請參閱附錄::ref:`setting-envvars`,了解其他啟動Python的方式。</td> |
| 203 | +</tr> |
| 204 | +<tr class='i'> |
| 205 | +<td class='src' lang='en'> |
| 206 | +Typing an end-of-file character (:kbd:`Control-D` on Unix, :kbd:`Control-Z` on Windows) at the primary prompt causes the interpreter to exit with a zero exit status. If that doesn't work, you can exit the interpreter by typing the following command: ``quit()``.</td> |
| 207 | +<td class='tra' lang='zh-TW'> |
| 208 | +在主提示符輸入一個 end-of-file 字元(在 Unix 上為 :kbd:`Control-D`\ ;在 Windows 上為 :kbd:`Control-Z`\ )會使得直譯器以零退出狀況 (zero exit status) 離開。如果上述的做法沒有效,也可以輸入指令 ``quit()`` 離開直譯器。</td> |
| 209 | +</tr> |
| 210 | +<tr class='i'> |
| 211 | +<td class='src' lang='en'> |
| 212 | +The interpreter's line-editing features include interactive editing, history substitution and code completion on systems that support the `GNU Readline <https://tiswww.case.edu/php/chet/readline/rltop.html>`_ library. Perhaps the quickest check to see whether command line editing is supported is typing :kbd:`Control-P` to the first Python prompt you get. If it beeps, you have command line editing; see Appendix :ref:`tut-interacting` for an introduction to the keys. If nothing appears to happen, or if ``^P`` is echoed, command line editing isn't available; you'll only be able to use backspace to remove characters from the current line.</td> |
| 213 | +<td class='tra' lang='zh-TW'> |
| 214 | +直譯器的指令列編輯功能有很多,在支援 `GNU Readline <https://tiswww.case.edu/php/chet/readline/rltop.html>` 函式庫的系統上包含:互動編輯、歷史取代、指令補完等功能。最快檢查有無支援指令列編輯的方法為:在第一個 Python 提示符後輸入 :kbd:`Control-P` ,如果出現嗶嗶聲,就代表有支援;見附錄 :ref:`tut-interacting` 介紹相關的快速鍵。如果什麼事沒有發生,或者出現一個 ``^P`` ,就代表並沒有指令列編輯功能;此時只能使用 backspace 去除該行的字元。</td> |
| 215 | +</tr> |
| 216 | +<tr class='i'> |
| 217 | +<td class='src' lang='en'> |
| 218 | +The interpreter operates somewhat like the Unix shell: when called with standard input connected to a tty device, it reads and executes commands interactively; when called with a file name argument or with a file as standard input, it reads and executes a *script* from that file.</td> |
| 219 | +<td class='tra' lang='zh-TW'> |
| 220 | +這個直譯器使用起來像是 Unix shell:如果它被呼叫時連結至一個 tty 裝置,它會互動式地讀取並執行指令;如果被呼叫時給定檔名為引數或者使用 stdin 傳入檔案內容,它會將這個檔案視為\ **腳本**\ 來閱讀。</td> |
| 221 | +</tr> |
| 222 | +<tr class='i'> |
| 223 | +<td class='src' lang='en'> |
| 224 | +A second way of starting the interpreter is ``python -c command [arg] ...``, which executes the statement(s) in *command*, analogous to the shell's :option:`-c` option. Since Python statements often contain spaces or other characters that are special to the shell, it is usually advised to quote *command* in its entirety with single quotes.</td> |
| 225 | +<td class='tra' lang='zh-TW'> |
| 226 | +另一個啟動直譯器的方式為 ``python -c command [arg] ...`` ,它會執行在 *command* 裡的指令(們),行為如同 shell 的 :option:`-c` 選項。因為 Python 的指令包含空白等 shell 用到的特殊字元,通常建議用單引號把 *command* 包起來。</td> |
| 227 | +</tr> |
| 228 | +<tr class='i'> |
| 229 | +<td class='src' lang='en'> |
| 230 | +Some Python modules are also useful as scripts. These can be invoked using ``python -m module [arg] ...``, which executes the source file for *module* as if you had spelled out its full name on the command line.</td> |
| 231 | +<td class='tra' lang='zh-TW'> |
| 232 | +有些 Python 模組使用上如腳本般一樣方便。透過 ``python -m module [arg] ...`` 可以執行 *module* 模組的原始碼,就如同直接傳入那個模組的完整路徑一樣的行為。</td> |
| 233 | +</tr> |
| 234 | +<tr class='i'> |
| 235 | +<td class='src' lang='en'> |
| 236 | +When a script file is used, it is sometimes useful to be able to run the script and enter interactive mode afterwards. This can be done by passing :option:`-i` before the script.</td> |
| 237 | +<td class='tra' lang='zh-TW'> |
| 238 | +當要執行一個腳本檔時,有時候會希望在腳本結束時進入互動模式。此時可在執行腳本的指令加入 :option:`-i` 。</td> |
| 239 | +</tr> |
| 240 | +<tr class='i'> |
| 241 | +<td class='src' lang='en'> |
| 242 | +All command line options are described in :ref:`using-on-general`.</td> |
| 243 | +<td class='tra' lang='zh-TW'> |
| 244 | +所有指令可用的參數都詳記在 :ref:`using-on-general` 。</td> |
| 245 | +</tr> |
| 246 | +<tr class='i'> |
| 247 | +<td class='src' lang='en'> |
| 248 | +Argument Passing</td> |
| 249 | +<td class='tra' lang='zh-TW'> |
| 250 | +傳遞引數</td> |
| 251 | +</tr> |
| 252 | +<tr class='i'> |
| 253 | +<td class='src' lang='en'> |
| 254 | +When known to the interpreter, the script name and additional arguments thereafter are turned into a list of strings and assigned to the ``argv`` variable in the ``sys`` module. You can access this list by executing ``import sys``. The length of the list is at least one; when no script and no arguments are given, ``sys.argv[0]`` is an empty string. When the script name is given as ``'-'`` (meaning standard input), ``sys.argv[0]`` is set to ``'-'``. When :option:`-c` *command* is used, ``sys.argv[0]`` is set to ``'-c'``. When :option:`-m` *module* is used, ``sys.argv[0]`` is set to the full name of the located module. Options found after :option:`-c` *command* or :option:`-m` *module* are not consumed by the Python interpreter's option processing but left in ``sys.argv`` for the command or module to handle.</td> |
| 255 | +<td class='tra' lang='zh-TW'> |
| 256 | +當直擇器收到腳本的名稱和額外的引數後,他們會轉換為由字串所組成的 list(串列)並指派給 ``sys`` 模組的 ``argv`` 變數。你可以執行 ``import sys`` 取得這個串列。這個串列的長度至少為一;當沒有給任何腳本名稱和引數時, ``sys.argv[0]`` 為空字串。當腳本名為 ``'-'`` (指標準輸入)時, ``sys.argv[0]`` 為 ``'-'`` 。當使用 :option:`-c` *command* 時, ``sys.argv[0]`` 為 ``'-c'``\ 。當使用 :option:`-m` *module* 時, ``sys.argv[0]`` 為該模組存在的完整路徑。其餘非 :option:`-c` *command* 或 :option:`-m` *module* 的選項不會被 Python 直譯器吸收掉,而是留在 ``sys.argv`` 變數中給後續的 command 或 module 使用。</td> |
| 257 | +</tr> |
| 258 | +<tr class='i'> |
| 259 | +<td class='src' lang='en'> |
| 260 | +Interactive Mode</td> |
| 261 | +<td class='tra' lang='zh-TW'> |
| 262 | +互動模式</td> |
| 263 | +</tr> |
| 264 | +<tr class='i'> |
| 265 | +<td class='src' lang='en'> |
| 266 | +When commands are read from a tty, the interpreter is said to be in *interactive mode*. In this mode it prompts for the next command with the *primary prompt*, usually three greater-than signs (``>>>``); for continuation lines it prompts with the *secondary prompt*, by default three dots (``...``). The interpreter prints a welcome message stating its version number and a copyright notice before printing the first prompt:</td> |
| 267 | +<td class='tra' lang='zh-TW'> |
| 268 | +在終端(tty)輸入並執行指令時,解釋器在*互動模式(interactive mode)*中運行。在這種模式中,會顯示*主提示符*,提示輸入下一條指令,主提示符通常用三個大於號(``>>>``)表示;輸入連續行時,顯示*次要提示符*,預設是三個點(``...``)。進入解釋器時,首先顯示歡迎信息、版本信息、版權聲明,然後才是提示符: |
| 269 | +<br> |
| 270 | +<br>::</td> |
| 271 | +</tr> |
| 272 | +<tr class='i'> |
| 273 | +<td class='src' lang='en'> |
| 274 | +Continuation lines are needed when entering a multi-line construct. As an example, take a look at this :keyword:`if` statement::</td> |
| 275 | +<td class='tra' lang='zh-TW'> |
| 276 | +接續多行的情況出現在需要多行才能建立完整指令時。舉例來說,像是 :keyword:`if` 敘述: |
| 277 | +<br> |
| 278 | +<br>::</td> |
| 279 | +</tr> |
| 280 | +<tr class='i'> |
| 281 | +<td class='src' lang='en'> |
| 282 | +For more on interactive mode, see :ref:`tut-interac`.</td> |
| 283 | +<td class='tra' lang='zh-TW'> |
| 284 | +更多有關互動模式的使用,請見\ :ref:`tut-interac`\ 。</td> |
| 285 | +</tr> |
| 286 | +<tr class='i'> |
| 287 | +<td class='src' lang='en'> |
| 288 | +The Interpreter and Its Environment</td> |
| 289 | +<td class='tra' lang='zh-TW'> |
| 290 | +直譯器與它的環境</td> |
| 291 | +</tr> |
| 292 | +<tr class='i'> |
| 293 | +<td class='src' lang='en'> |
| 294 | +Source Code Encoding</td> |
| 295 | +<td class='tra' lang='zh-TW'> |
| 296 | +原始碼的字元編碼 (encoding)</td> |
| 297 | +</tr> |
| 298 | +<tr class='i'> |
| 299 | +<td class='src' lang='en'> |
| 300 | +By default, Python source files are treated as encoded in UTF-8. In that encoding, characters of most languages in the world can be used simultaneously in string literals, identifiers and comments --- although the standard library only uses ASCII characters for identifiers, a convention that any portable code should follow. To display all these characters properly, your editor must recognize that the file is UTF-8, and it must use a font that supports all the characters in the file.</td> |
| 301 | +<td class='tra' lang='zh-TW'> |
| 302 | +預設 Python 原始碼檔案的字元編碼使用 UTF-8。在這個編碼中,世界上多數語言的文字可以同時被使用在字串內容、識別名 (identifier) 及註解中 --- 雖然在標準函式庫中只使用 ASCII 字元作為識別名,這也是個任何 portable 程式碼需遵守的慣例。如果要正確地顯示所有字元,您的編輯器需要能夠認識檔案為 UTF-8,並且需要能顯示檔案中所有字元的字型。</td> |
| 303 | +</tr> |
| 304 | +<tr class='i'> |
| 305 | +<td class='src' lang='en'> |
| 306 | +To declare an encoding other than the default one, a special comment line should be added as the *first* line of the file. The syntax is as follows::</td> |
| 307 | +<td class='tra' lang='zh-TW'> |
| 308 | +如果不使用預設編碼,則要聲明文件的編碼,文件的*第一*行要寫成特殊註釋。句法如下: |
| 309 | +<br> |
| 310 | +<br>::</td> |
| 311 | +</tr> |
| 312 | +<tr class='i'> |
| 313 | +<td class='src' lang='en'> |
| 314 | +where *encoding* is one of the valid :mod:`codecs` supported by Python.</td> |
| 315 | +<td class='tra' lang='zh-TW'> |
| 316 | +其中, *encoding* 可以是Python支持的任意一種 :mod:`codecs` 。</td> |
| 317 | +</tr> |
| 318 | +<tr class='i'> |
| 319 | +<td class='src' lang='en'> |
| 320 | +For example, to declare that Windows-1252 encoding is to be used, the first line of your source code file should be::</td> |
| 321 | +<td class='tra' lang='zh-TW'> |
| 322 | +比如,聲明使用Windows-1252 編碼,源碼文件要寫成: |
| 323 | +<br> |
| 324 | +<br>::</td> |
| 325 | +</tr> |
| 326 | +<tr class='i'> |
| 327 | +<td class='src' lang='en'> |
| 328 | +One exception to the *first line* rule is when the source code starts with a :ref:`UNIX "shebang" line <tut-scripts>`. In this case, the encoding declaration should be added a
A7FE
s the second line of the file. For example::</td> |
| 329 | +<td class='tra' lang='zh-TW'> |
| 330 | +*第一行*的規則也有一種例外情況,在源碼以 :ref:`UNIX "shebang" line <tut-scripts>` 行開頭時。此時,編碼聲明要寫在文件的第二行。例如: |
| 331 | +<br> |
| 332 | +<br>::</td> |
| 333 | +</tr> |
| 334 | +<tr class='i'> |
| 335 | +<td class='src' lang='en'> |
| 336 | +Footnotes</td> |
| 337 | +<td class='tra' lang='zh-TW'> |
| 338 | +註解</td> |
| 339 | +</tr> |
| 340 | +<tr class='i'> |
| 341 | +<td class='src' lang='en'> |
| 342 | +On Unix, the Python 3.x interpreter is by default not installed with the executable named ``python``, so that it does not conflict with a simultaneously installed Python 2.x executable.</td> |
| 343 | +<td class='tra' lang='zh-TW'> |
| 344 | +在 Unix 中,Python 3.x 直譯器預設安裝不會以 ``python`` 作為執行檔名稱,以避免與 現有的 Python 2.x 執行檔名稱衝突。</td> |
| 345 | +</tr> |
| 346 | +</tbody> |
| 347 | +</table> |
| 348 | +</div> |
| 349 | +</body> |
| 350 | +</html> |
0 commit comments