-
-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathindex.html
503 lines (460 loc) · 33.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<!DOCTYPE html>
<html lang="zh-TW" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Python 教學 — Python 3.13.2 說明文件</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=23252803" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />
<script src="../_static/documentation_options.js?v=9a295789"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/translations.js?v=cbf116e0"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="在 Python 3.13.2 說明文件 中搜尋"
href="../_static/opensearch.xml"/>
<link rel="author" title="關於這些文件" href="../about.html" />
<link rel="index" title="索引" href="../genindex.html" />
<link rel="search" title="搜尋" href="../search.html" />
<link rel="copyright" title="版權" href="../copyright.html" />
<link rel="next" title="1. 淺嘗滋味" href="appetite.html" />
<link rel="prev" title="Changelog(更動日誌)" href="../whatsnew/changelog.html" />
<link rel="canonical" href="https://docs.python.org/3/tutorial/index.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/search-focus.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
<script type="text/javascript" src="../_static/rtd_switcher.js"></script>
<meta name="readthedocs-addons-api-version" content="1">
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Python logo"/>
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
</svg>
<input placeholder="快速搜尋" aria-label="快速搜尋" type="search" name="q" />
<input type="submit" value="前往"/>
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h4>上個主題</h4>
<p class="topless"><a href="../whatsnew/changelog.html"
title="上一章">Changelog(更動日誌)</a></p>
</div>
<div>
<h4>下個主題</h4>
<p class="topless"><a href="appetite.html"
title="下一章"><span class="section-number">1. </span>淺嘗滋味</a></p>
</div>
<div role="note" aria-label="source link">
<h3>此頁面</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">回報錯誤</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/tutorial/index.rst"
rel="nofollow">顯示原始碼
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>瀏覽</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="總索引"
accesskey="I">索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python 模組索引"
>模組</a> |</li>
<li class="right" >
<a href="appetite.html" title="1. 淺嘗滋味"
accesskey="N">下一頁</a> |</li>
<li class="right" >
<a href="../whatsnew/changelog.html" title="Changelog(更動日誌)"
accesskey="P">上一頁</a> |</li>
<li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.13.2 Documentation</a> »
</li>
<li class="nav-item nav-item-this"><a href="">Python 教學</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="快速搜尋" aria-label="快速搜尋" type="search" name="q" id="search-box" />
<input type="submit" value="前往" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="the-python-tutorial">
<span id="tutorial-index"></span><h1>Python 教學<a class="headerlink" href="#the-python-tutorial" title="連結到這個標頭">¶</a></h1>
<p>Python 是一種易學、功能強大的程式語言。它有高效能的高階資料結構,也有簡單但有效的方法去實現物件導向程式設計。Python 優雅的語法和動態型別,結合其直譯特性,使它成為眾多領域和大多數平臺上,撰寫腳本和快速開發應用程式的理想語言。</p>
<p>使用者可以自由且免費地從 Python 官網上 (<a class="reference external" href="https://www.python.org/">https://www.python.org/</a>) 取得各大平台上用的 Python 直譯器和標準函式庫,下載其源碼或二進位形式執行檔,同時,也可以將其自由地散佈。另外,Python 官網也提供了許多自由且免費的第三方 Python 模組、程式與工具、以及額外說明文件,有興趣的使用者,可在官網上找到相關的發行版本與連結網址。</p>
<p>使用 C 或 C++(或其他可被 C 呼叫的程式語言),可以很容易在 Python 直譯器內新增功能函式及資料型別。同時,對可讓使用者自製功能的應用程式來說,Python 也適合作為其擴充用介面語言 (extension language)。</p>
<p>這份教學將簡介 Python 語言與系統的基本概念及功能。除了閱讀之外、實際用 Python 直譯器寫程式跑範例,將有助於學習。但如果只用讀的,也是可行的學習方式,因為所有範例的內容皆獨立且完整。</p>
<p>若想了解 Python 標準物件和模組的描述,請參閱 <a class="reference internal" href="../library/index.html#library-index"><span class="std std-ref">Python 標準函式庫 (Standard Library)</span></a>。在 <a class="reference internal" href="../reference/index.html#reference-index"><span class="std std-ref">Python 語言參考手冊</span></a> 中,你可以學到 Python 語言更正規的定義。想用 C 或 C++ 寫延伸套件 (extensions) 的讀者,請閱讀 <a class="reference internal" href="../extending/index.html#extending-index"><span class="std std-ref">擴充和嵌入 Python 直譯器</span></a> 和 <a class="reference internal" href="../c-api/index.html#c-api-index"><span class="std std-ref">Python/C API 參考手冊</span></a> 。此外,市面上也能找到更深入的 Python 學習書。</p>
<p>這份教學中,我們不會介紹每一個功能,甚至,也不打算介紹完每一個常用功能。取而代之,我們的重心將放在介紹 Python 中最值得一提的那些功能,幫助你了解 Python 語言的特色與風格。讀完教學後,你將有能力閱讀和撰寫 Python 模組與程式,也做好進一步學習 <a class="reference internal" href="../library/index.html#library-index"><span class="std std-ref">Python 標準函式庫 (Standard Library)</span></a> 中各類型的 Python 函式庫模組的準備。</p>
<p><a class="reference internal" href="../glossary.html#glossary"><span class="std std-ref">術語表</span></a> 頁面也值得細讀。</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="appetite.html">1. 淺嘗滋味</a></li>
<li class="toctree-l1"><a class="reference internal" href="interpreter.html">2. 使用 Python 直譯器</a><ul>
<li class="toctree-l2"><a class="reference internal" href="interpreter.html#invoking-the-interpreter">2.1. 啟動直譯器</a><ul>
<li class="toctree-l3"><a class="reference internal" href="interpreter.html#argument-passing">2.1.1. 傳遞引數</a></li>
<li class="toctree-l3"><a class="reference internal" href="interpreter.html#interactive-mode">2.1.2. 互動模式</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="interpreter.html#the-interpreter-and-its-environment">2.2. 直譯器與它的環境</a><ul>
<li class="toctree-l3"><a class="reference internal" href="interpreter.html#source-code-encoding">2.2.1. 原始碼的字元編碼 (encoding)</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">3. 一個非正式的 Python 簡介</a><ul>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#using-python-as-a-calculator">3.1. 把 Python 當作計算機使用</a><ul>
<li class="toctree-l3"><a class="reference internal" href="introduction.html#numbers">3.1.1. 數字 (Number)</a></li>
<li class="toctree-l3"><a class="reference internal" href="introduction.html#text">3.1.2. 文字</a></li>
<li class="toctree-l3"><a class="reference internal" href="introduction.html#lists">3.1.3. List(串列)</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="introduction.html#first-steps-towards-programming">3.2. 初探程式設計的前幾步</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="controlflow.html">4. 深入了解流程控制</a><ul>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#if-statements">4.1. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">if</span></code> 陳述式</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#for-statements">4.2. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code> 陳述式</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#the-range-function">4.3. <code class="xref py py-func docutils literal notranslate"><span class="pre">range()</span></code> 函式</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#break-and-continue-statements">4.4. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">break</span></code> 和 <code class="xref std std-keyword docutils literal notranslate"><span class="pre">continue</span></code> 陳述式</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#else-clauses-on-loops">4.5. 迴圈的 <code class="xref std std-keyword docutils literal notranslate"><span class="pre">else</span></code> 子句</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#pass-statements">4.6. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">pass</span></code> 陳述式</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#match-statements">4.7. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">match</span></code> 陳述式</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#defining-functions">4.8. 定義函式 (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#more-on-defining-functions">4.9. 深入了解函式定義</a><ul>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#default-argument-values">4.9.1. 預設引數值</a></li>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#keyword-arguments">4.9.2. 關鍵字引數</a></li>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#special-parameters">4.9.3. 特殊參數</a><ul>
<li class="toctree-l4"><a class="reference internal" href="controlflow.html#positional-or-keyword-arguments">4.9.3.1. 位置或關鍵字引數 (Positional-or-Keyword Arguments)</a></li>
<li class="toctree-l4"><a class="reference internal" href="controlflow.html#positional-only-parameters">4.9.3.2. 僅限位置參數 (Positional-Only Parameters)</a></li>
<li class="toctree-l4"><a class="reference internal" href="controlflow.html#keyword-only-arguments">4.9.3.3. 僅限關鍵字引數 (Keyword-Only Arguments)</a></li>
<li class="toctree-l4"><a class="reference internal" href="controlflow.html#function-examples">4.9.3.4. 函式範例</a></li>
<li class="toctree-l4"><a class="reference internal" href="controlflow.html#recap">4.9.3.5. 回顧</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#arbitrary-argument-lists">4.9.4. 任意引數列表 (Arbitrary Argument Lists)</a></li>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#unpacking-argument-lists">4.9.5. 拆解引數列表(Unpacking Argument Lists)</a></li>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#lambda-expressions">4.9.6. Lambda 運算式</a></li>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#documentation-strings">4.9.7. 說明文件字串 (Documentation Strings)</a></li>
<li class="toctree-l3"><a class="reference internal" href="controlflow.html#function-annotations">4.9.8. 函式註釋 (Function Annotations)</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="controlflow.html#intermezzo-coding-style">4.10. 間奏曲:程式碼風格 (Coding Style)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="datastructures.html">5. 資料結構</a><ul>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#more-on-lists">5.1. 進一步了解 List(串列)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="datastructures.html#using-lists-as-stacks">5.1.1. 將 List 作為 Stack(堆疊)使用</a></li>
<li class="toctree-l3"><a class="reference internal" href="datastructures.html#using-lists-as-queues">5.1.2. 將 List 作為 Queue(佇列)使用</a></li>
<li class="toctree-l3"><a class="reference internal" href="datastructures.html#list-comprehensions">5.1.3. List Comprehensions(串列綜合運算)</a></li>
<li class="toctree-l3"><a class="reference internal" href="datastructures.html#nested-list-comprehensions">5.1.4. 巢狀的 List Comprehensions</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#the-del-statement">5.2. <code class="xref std std-keyword docutils literal notranslate"><span class="pre">del</span></code> 陳述式</a></li>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#tuples-and-sequences">5.3. Tuples 和序列 (Sequences)</a></li>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#sets">5.4. 集合 (Sets)</a></li>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#dictionaries">5.5. 字典(Dictionary)</a></li>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#looping-techniques">5.6. 迴圈技巧</a></li>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#more-on-conditions">5.7. 深入了解條件 (Condition)</a></li>
<li class="toctree-l2"><a class="reference internal" href="datastructures.html#comparing-sequences-and-other-types">5.8. 序列和其他資料類型之比較</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules.html">6. 模組 (Module)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules.html#more-on-modules">6.1. 深入了解模組</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules.html#executing-modules-as-scripts">6.1.1. 把模組當作腳本執行</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules.html#the-module-search-path">6.1.2. 模組的搜尋路徑</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules.html#compiled-python-files">6.1.3. 「編譯」Python 檔案</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#standard-modules">6.2. 標準模組</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#the-dir-function">6.3. <code class="xref py py-func docutils literal notranslate"><span class="pre">dir()</span></code> 函式</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules.html#packages">6.4. 套件 (Package)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules.html#importing-from-a-package">6.4.1. 從套件中 import *</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules.html#intra-package-references">6.4.2. 套件內引用</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules.html#packages-in-multiple-directories">6.4.3. 多目錄中的套件</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="inputoutput.html">7. 輸入和輸出</a><ul>
<li class="toctree-l2"><a class="reference internal" href="inputoutput.html#fancier-output-formatting">7.1. 更華麗的輸出格式</a><ul>
<li class="toctree-l3"><a class="reference internal" href="inputoutput.html#formatted-string-literals">7.1.1. 格式化的字串文本 (Formatted String Literals)</a></li>
<li class="toctree-l3"><a class="reference internal" href="inputoutput.html#the-string-format-method">7.1.2. 字串的 format() method</a></li>
<li class="toctree-l3"><a class="reference internal" href="inputoutput.html#manual-string-formatting">7.1.3. 手動格式化字串</a></li>
<li class="toctree-l3"><a class="reference internal" href="inputoutput.html#old-string-formatting">7.1.4. 格式化字串的舊方法</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="inputoutput.html#reading-and-writing-files">7.2. 讀寫檔案</a><ul>
<li class="toctree-l3"><a class="reference internal" href="inputoutput.html#methods-of-file-objects">7.2.1. 檔案物件的 method</a></li>
<li class="toctree-l3"><a class="reference internal" href="inputoutput.html#saving-structured-data-with-json">7.2.2. 使用 <code class="xref py py-mod docutils literal notranslate"><span class="pre">json</span></code> 儲存結構化資料</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="errors.html">8. 錯誤和例外</a><ul>
<li class="toctree-l2"><a class="reference internal" href="errors.html#syntax-errors">8.1. 語法錯誤 (Syntax Error)</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#exceptions">8.2. 例外 (Exception)</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#handling-exceptions">8.3. 處理例外</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#raising-exceptions">8.4. 引發例外</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#exception-chaining">8.5. 例外鏈接 (Exception Chaining)</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#user-defined-exceptions">8.6. 使用者自定的例外</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#defining-clean-up-actions">8.7. 定義清理動作</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#predefined-clean-up-actions">8.8. 預定義的清理動作</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#raising-and-handling-multiple-unrelated-exceptions">8.9. 引發及處理多個無關的例外</a></li>
<li class="toctree-l2"><a class="reference internal" href="errors.html#enriching-exceptions-with-notes">8.10. 用註解使例外更詳細</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="classes.html">9. Class(類別)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="classes.html#a-word-about-names-and-objects">9.1. 關於名稱與物件的一段話</a></li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#python-scopes-and-namespaces">9.2. Python 作用域 (Scope) 及命名空間 (Namespace)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="classes.html#scopes-and-namespaces-example">9.2.1. 作用域和命名空間的範例</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#a-first-look-at-classes">9.3. 初見 class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="classes.html#class-definition-syntax">9.3.1. Class definition(類別定義)語法</a></li>
<li class="toctree-l3"><a class="reference internal" href="classes.html#class-objects">9.3.2. Class 物件</a></li>
<li class="toctree-l3"><a class="reference internal" href="classes.html#instance-objects">9.3.3. 實例物件</a></li>
<li class="toctree-l3"><a class="reference internal" href="classes.html#method-objects">9.3.4. Method 物件</a></li>
<li class="toctree-l3"><a class="reference internal" href="classes.html#class-and-instance-variables">9.3.5. Class 及實例變數</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#random-remarks">9.4. 隨意的備註</a></li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#inheritance">9.5. 繼承 (Inheritance)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="classes.html#multiple-inheritance">9.5.1. 多重繼承</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#private-variables">9.6. 私有變數</a></li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#odds-and-ends">9.7. 補充說明</a></li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#iterators">9.8. 疊代器 (Iterator)</a></li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#generators">9.9. 產生器 (Generator)</a></li>
<li class="toctree-l2"><a class="reference internal" href="classes.html#generator-expressions">9.10. 產生器運算式</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="stdlib.html">10. Python 標準函式庫概覽</a><ul>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#operating-system-interface">10.1. 作業系統介面</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#file-wildcards">10.2. 檔案之萬用字元 (File Wildcards)</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#command-line-arguments">10.3. 命令列引數</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#error-output-redirection-and-program-termination">10.4. 錯誤輸出重新導向與程式終止</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#string-pattern-matching">10.5. 字串樣式比對</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#mathematics">10.6. 數學相關</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#internet-access">10.7. 網路存取</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#dates-and-times">10.8. 日期與時間</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#data-compression">10.9. 資料壓縮</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#performance-measurement">10.10. 效能量測</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#quality-control">10.11. 品質控管</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib.html#batteries-included">10.12. 標準模組庫</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="stdlib2.html">11. Python 標準函式庫概覽——第二部份</a><ul>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#output-formatting">11.1. 輸出格式化 (Output Formatting)</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#templating">11.2. 模板化 (Templating)</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#working-with-binary-data-record-layouts">11.3. 二進制資料記錄編排 (Binary Data Record Layouts)</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#multi-threading">11.4. 多執行緒 (Multi-threading)</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#logging">11.5. 日誌記錄 (Logging)</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#weak-references">11.6. 弱引用 (Weak References)</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#tools-for-working-with-lists">11.7. 使用於 List 的工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib2.html#decimal-floating-point-arithmetic">11.8. 十進制浮點數運算 (Decimal Floating-Point Arithmetic)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="venv.html">12. 虛擬環境與套件</a><ul>
<li class="toctree-l2"><a class="reference internal" href="venv.html#introduction">12.1. 簡介</a></li>
<li class="toctree-l2"><a class="reference internal" href="venv.html#creating-virtual-environments">12.2. 建立虛擬環境</a></li>
<li class="toctree-l2"><a class="reference internal" href="venv.html#managing-packages-with-pip">12.3. 用 pip 管理套件</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="whatnow.html">13. 現在可以來學習些什麼?</a></li>
<li class="toctree-l1"><a class="reference internal" href="interactive.html">14. 互動式輸入編輯和歷史記錄替換</a><ul>
<li class="toctree-l2"><a class="reference internal" href="interactive.html#tab-completion-and-history-editing">14.1. Tab 鍵自動完成 (Tab Completion) 和歷史記錄編輯 (History Editing)</a></li>
<li class="toctree-l2"><a class="reference internal" href="interactive.html#alternatives-to-the-interactive-interpreter">14.2. 互動式直譯器的替代方案</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="floatingpoint.html">15. 浮點數運算:問題與限制</a><ul>
<li class="toctree-l2"><a class="reference internal" href="floatingpoint.html#representation-error">15.1. 表示法誤差 (Representation Error)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="appendix.html">16. 附錄</a><ul>
<li class="toctree-l2"><a class="reference internal" href="appendix.html#interactive-mode">16.1. 互動模式</a><ul>
<li class="toctree-l3"><a class="reference internal" href="appendix.html#error-handling">16.1.1. 錯誤處理</a></li>
<li class="toctree-l3"><a class="reference internal" href="appendix.html#executable-python-scripts">16.1.2. 可執行的 Python 腳本</a></li>
<li class="toctree-l3"><a class="reference internal" href="appendix.html#the-interactive-startup-file">16.1.3. 互動式啟動檔案</a></li>
<li class="toctree-l3"><a class="reference internal" href="appendix.html#the-customization-modules">16.1.4. 客製化模組</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<div>
<h4>上個主題</h4>
<p class="topless"><a href="../whatsnew/changelog.html"
title="上一章">Changelog(更動日誌)</a></p>
</div>
<div>
<h4>下個主題</h4>
<p class="topless"><a href="appetite.html"
title="下一章"><span class="section-number">1. </span>淺嘗滋味</a></p>
</div>
<div role="note" aria-label="source link">
<h3>此頁面</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">回報錯誤</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/tutorial/index.rst"
rel="nofollow">顯示原始碼
</a>
</li>
</ul>
</div>
</div>
<div id="sidebarbutton" title="收合側邊欄">
<span>«</span>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>瀏覽</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="總索引"
>索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python 模組索引"
>模組</a> |</li>
<li class="right" >
<a href="appetite.html" title="1. 淺嘗滋味"
>下一頁</a> |</li>
<li class="right" >
<a href="../whatsnew/changelog.html" title="Changelog(更動日誌)"
>上一頁</a> |</li>
<li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.13.2 Documentation</a> »
</li>
<li class="nav-item nav-item-this"><a href="">Python 教學</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="快速搜尋" aria-label="快速搜尋" type="search" name="q" id="search-box" />
<input type="submit" value="前往" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="footer">
©
<a href="../copyright.html">
版權
</a>
2001-2025, Python Software Foundation.
<br />
This page is licensed under the Python Software Foundation License Version 2.
<br />
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br />
See <a href="/license.html">History and License</a> for more information.<br />
<br />
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
<br />
最後更新於 3月 15, 2025 (12:46 UTC)。
<a href="/bugs.html">Found a bug</a>?
<br />
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3 建立。
</div>
</body>
</html>