---
title: "Python 手册"
author: "mmdev"
date: "2007-07-23T20:52:00Z"
tags: []
slug: "python"
draft: false
lastmod: "2012-03-28T22:21:37Z"
id: 1467838
url: "https://mmdev.iteye.com/blog/1467838"
---

[Python中文社区](http://www.python.cn/)

![](http://doc.chinahtml.com/Manual/Python/icons/blank.gif) [![Up One Level](http://doc.chinahtml.com/Manual/Python/icons/up.gif)](http://doc.chinahtml.com/Manual/Python/index.html "Python Documentation Index") [![Next Page](http://doc.chinahtml.com/Manual/Python/icons/next.gif)](http://doc.chinahtml.com/Manual/Python/tut/node1.html "Front Matter") Python 手册 [![Contents](http://doc.chinahtml.com/Manual/Python/icons/contents.gif)](http://doc.chinahtml.com/Manual/Python/tut/node2.html "Table of Contents") ![](http://doc.chinahtml.com/Manual/Python/icons/blank.gif)

**向上：**[Python **文档索引**](http://doc.chinahtml.com/Manual/Python/index.html) **向后：**[前言](http://doc.chinahtml.com/Manual/Python/tut/node1.html)

* * *

&lt;!--End of Navigation Panel--&gt;

&lt;link title="Python Documentation Index" href="../index.html" rel="up"&gt;

# Python **手册**

**Guido van Rossum**  
**Fred L. Drake, Jr., editor**

**PythonLabs**  
Email: python-docs@python.org

**Release 2.3**  
**July 29, 2003**

* * *

&lt;!--Table of Child-Links--&gt;[]()

- [前言](http://doc.chinahtml.com/Manual/Python/tut/node1.html)
- [目录](http://doc.chinahtml.com/Manual/Python/tut/node2.html)
- [1. 开胃菜](http://doc.chinahtml.com/Manual/Python/tut/node3.html)
- [2. 使用Python解释器](http://doc.chinahtml.com/Manual/Python/tut/node4.html)
  
  - [2.1 调用解释器](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004100000000000000000)
    
    - [2.1.1 传递参数](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004110000000000000000)
    - [2.1.2 交互模式](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004120000000000000000)
  - [2.2 解释器及其工作模式](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004200000000000000000)
    
    - [2.2.1 错误处理](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004210000000000000000)
    - [2.2.2 执行 Python 脚本](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004220000000000000000)
    - [2.2.3 源程序编码](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004230000000000000000)
    - [2.2.4 交互环境的启动文件](http://doc.chinahtml.com/Manual/Python/tut/node4.html#SECTION004240000000000000000)
- [3.初步认识 Python](http://doc.chinahtml.com/Manual/Python/tut/node5.html)
  
  - [3.1 像使用计算器一样使用Python](http://doc.chinahtml.com/Manual/Python/tut/node5.html#SECTION005100000000000000000)
    
    - [3.1.1 数值](http://doc.chinahtml.com/Manual/Python/tut/node5.html#SECTION005110000000000000000)
    - [3.1.2 字符串](http://doc.chinahtml.com/Manual/Python/tut/node5.html#SECTION005120000000000000000)
    - [3.1.3 Unicode 字符串](http://doc.chinahtml.com/Manual/Python/tut/node5.html#SECTION005130000000000000000)
    - [3.1.4 链表](http://doc.chinahtml.com/Manual/Python/tut/node5.html#SECTION005140000000000000000)
  - [3.2 开始编程](http://doc.chinahtml.com/Manual/Python/tut/node5.html#SECTION005200000000000000000)
- [4. 流程控制](http://doc.chinahtml.com/Manual/Python/tut/node6.html)
  
  - [4.1 `if` 语法](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006100000000000000000)
  - [4.2 `for` 语法](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006200000000000000000)
  - [4.3`range()` 函数](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006300000000000000000)
  - [4.4 `break` `和` `continue` 语法`以及 else` 子句 在循环中的用法](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006400000000000000000)
  - [4.5 `pass` 语法](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006500000000000000000)
  - [4.6 定义函数](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006600000000000000000)
  - [4.7 定义函数的进一步知识](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006700000000000000000)
    
    - [4.7.1 定义参数变量](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006710000000000000000)
    - [4.7.2 参数关键字](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006720000000000000000)
    - [4.7.3 可变参数表](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006730000000000000000)
    - [4.7.4 Lambda 结构](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006740000000000000000)
    - [4.7.5 文档字符串](http://doc.chinahtml.com/Manual/Python/tut/node6.html#SECTION006750000000000000000)
- [5. 数据结构](http://doc.chinahtml.com/Manual/Python/tut/node7.html)
  
  - [5.1 深入链表](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007100000000000000000)
    
    - [5.1.1 将链表作为堆栈来使用](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007110000000000000000)
    - [5.1.2 将链表作为队列来使用](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007120000000000000000)
    - [5.1.3 函数化的编程工具](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007130000000000000000)
    - [5.1.4 链表的内含（Comprehensions）](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007140000000000000000)
  - [5.2 `del` 语法](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007200000000000000000)
  - [5.3 Tuples 和 Sequences](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007300000000000000000)
  - [5.4 字典（Dictionaries）](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007400000000000000000)
  - [5.5 循环技巧](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007500000000000000000)
  - [5.6 深入条件控制](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007600000000000000000)
  - [5.7 Sequences 和其它类型的比较](http://doc.chinahtml.com/Manual/Python/tut/node7.html#SECTION007700000000000000000)
- [6. 模块](http://doc.chinahtml.com/Manual/Python/tut/node8.html)
  
  - [6.1 深入模块](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008100000000000000000)
    
    - [6.1.1 模块搜索路径](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008110000000000000000)
    - [6.1.2 “编译” Python 文件](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008120000000000000000)
  - [6.2 标准模块](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008200000000000000000)
  - [6.3 `dir()` 函数](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008300000000000000000)
  - [6.4 包](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008400000000000000000)
    
    - [6.4.1 从包中导入所有内容（import * )](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008410000000000000000)
    - [6.4.2 隐式包引用](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008420000000000000000)
    - [6.4.3 包中的多重路径](http://doc.chinahtml.com/Manual/Python/tut/node8.html#SECTION008430000000000000000)
- [7. 输入和输出](http://doc.chinahtml.com/Manual/Python/tut/node9.html)
  
  - [7.1 格式化输出](http://doc.chinahtml.com/Manual/Python/tut/node9.html#SECTION009100000000000000000)
  - [7.2 读写文件](http://doc.chinahtml.com/Manual/Python/tut/node9.html#SECTION009200000000000000000)
    
    - [7.2.1 文件对象的方法](http://doc.chinahtml.com/Manual/Python/tut/node9.html#SECTION009210000000000000000)
    - [7.2.2 `pickle` 模块](http://doc.chinahtml.com/Manual/Python/tut/node9.html#SECTION009220000000000000000)
- [8. 错误和异常](http://doc.chinahtml.com/Manual/Python/tut/node10.html)
  
  - [8.1 语法 Errors](http://doc.chinahtml.com/Manual/Python/tut/node10.html#SECTION0010100000000000000000)
  - [8.2 异常](http://doc.chinahtml.com/Manual/Python/tut/node10.html#SECTION0010200000000000000000)
  - [8.3 捕获异常](http://doc.chinahtml.com/Manual/Python/tut/node10.html#SECTION0010300000000000000000)
  - [8.4 释放异常](http://doc.chinahtml.com/Manual/Python/tut/node10.html#SECTION0010400000000000000000)
  - [8.5 用户自定义异常](http://doc.chinahtml.com/Manual/Python/tut/node10.html#SECTION0010500000000000000000)
  - [8.6 定义 Clean-up Actions](http://doc.chinahtml.com/Manual/Python/tut/node10.html#SECTION0010600000000000000000)
- [9. 类](http://doc.chinahtml.com/Manual/Python/tut/node11.html)
  
  - [9.1 一个术语](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011100000000000000000)
  - [9.2 Python 的生存期和命名空间](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011200000000000000000)
  - [9.3 类（Classes）的初步印像](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011300000000000000000)
    
    - [9.3.1 类定义语法](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011310000000000000000)
    - [9.3.2 类对象](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011320000000000000000)
    - [9.3.3 实例对象](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011330000000000000000)
    - [9.3.4 方法对象](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011340000000000000000)
  - [9.4 自由标记（Random Remarks）](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011400000000000000000)
  - [9.5 继承](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011500000000000000000)
    
    - [9.5.1 多继承](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011510000000000000000)
  - [9.6 私有变量](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011600000000000000000)
  - [9.7 零杂技巧](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011700000000000000000)
  - [9.8 异常也是类](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011800000000000000000)
  - [9.9 迭代子（Iterators）](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION0011900000000000000000)
  - [9.10 发生器（Generators）](http://doc.chinahtml.com/Manual/Python/tut/node11.html#SECTION00111000000000000000000)
- [10. 接下来？](http://doc.chinahtml.com/Manual/Python/tut/node12.html)
- [A. 交互式编辑和历史回溯](http://doc.chinahtml.com/Manual/Python/tut/node13.html)
  
  - [A.1 行编辑](http://doc.chinahtml.com/Manual/Python/tut/node13.html#SECTION0013100000000000000000)
  - [A.2 历史回溯](http://doc.chinahtml.com/Manual/Python/tut/node13.html#SECTION0013200000000000000000)
  - [A.3 快捷键绑定](http://doc.chinahtml.com/Manual/Python/tut/node13.html#SECTION0013300000000000000000)
  - [A.4 注释](http://doc.chinahtml.com/Manual/Python/tut/node13.html#SECTION0013400000000000000000)
- [B. 浮点计算：问题与极限](http://doc.chinahtml.com/Manual/Python/tut/node14.html)
  
  - [B.1 表达错误](http://doc.chinahtml.com/Manual/Python/tut/node14.html#SECTION0014100000000000000000)
- [C. 历史和授权](http://doc.chinahtml.com/Manual/Python/tut/node15.html)
  
  - [C.1 本软件的历史](http://doc.chinahtml.com/Manual/Python/tut/node15.html#SECTION0015100000000000000000)
  - [C.2 修改和使用Python的条件（Terms and conditions for accessing or otherwise using Python）](http://doc.chinahtml.com/Manual/Python/tut/node15.html#SECTION0015200000000000000000)
- [关于本文档](http://doc.chinahtml.com/Manual/Python/tut/node16.html)

&lt;!--End of Table of Child-Links--&gt;

* * *

![](http://doc.chinahtml.com/Manual/Python/icons/blank.gif) [![Up One Level](http://doc.chinahtml.com/Manual/Python/icons/up.gif)](http://doc.chinahtml.com/Manual/Python/index.html "Python Documentation Index") [![Next Page](http://doc.chinahtml.com/Manual/Python/icons/next.gif)](http://doc.chinahtml.com/Manual/Python/tut/node1.html "Front Matter") Python 手册 [![Contents](http://doc.chinahtml.com/Manual/Python/icons/contents.gif)](http://doc.chinahtml.com/Manual/Python/tut/node2.html "Table of Contents") ![](http://doc.chinahtml.com/Manual/Python/icons/blank.gif)

**向上：**[Python **文档索引**](http://doc.chinahtml.com/Manual/Python/index.html) **向后：**[前言](http://doc.chinahtml.com/Manual/Python/tut/node1.html)

* * *

Release 2.3, documentation updated on July 29, 2003.

&lt;!--End of Navigation Panel--&gt;

See [*About this document...*](http://doc.chinahtml.com/Manual/Python/tut/about.html) for information on suggesting changes.

[Python中文社区](http://www.python.cn/)