Python教程¶
Python是一种易于学习又功能强大的编程语言。它提供了高效的高层次的数据结构,还有简单有效的面向对象编程。Python优雅的语法和动态类型,以及解释型语言的本质,使它成为多数平台上写脚本和快速开发应用的理想语言。
多数平台上的Python解释器以及丰富的标准库的源码和执行文件,都可以在Python官网,https://www.python.org/,免费自由地下载。这个网站上也提供一些链接,包括第三方Python模块、程序、工具等,以及额外的文档。
Python解释器易于扩展,可以使用C或C++(或者其他可以从C调用的语言)扩展新的功能和数据类型。Python也可用于可定制化软件中的扩展程序语言。
这个教程非正式地介绍Python语言和系统的基本概念和功能。最好在阅读的时候有一个Python解释器做一些练习,不过所有的例子都是相互独立的,所以这个教程也可以离线阅读。
有关标准的对象和模块,参阅 The Python Standard Library。The Python Language Reference 提供了更正式的语言参考。要写C或者C++扩展,参考 Extending and Embedding the Python Interpreter 和 Python/C API Reference Manual。也有不少书籍深入讲解Python。
这个教程并没有完整包含每一个功能,甚至常用功能可能也没有全部涉及。这个教程只介绍Python中最值得注意的功能,也会让你体会到这个语言的风格特色。学习完这个教程,你将可以阅读和编写Python模块和程序,也可以开始学习更多的Python库模块,详见 The Python Standard Library。
Glossary 也很值得阅读一下。
- 1. 课前甜点
- 2. 使用 Python 解释器
- 3. Python 的非正式介绍
- 4. 其他的流程控制
- 5. Data Structures
- 6. Modules
- 7. Input and Output
- 8. Errors and Exceptions
- 9. Classes
- 10. Brief Tour of the Standard Library
- 10.1. Operating System Interface
- 10.2. File Wildcards
- 10.3. Command Line Arguments
- 10.4. Error Output Redirection and Program Termination
- 10.5. String Pattern Matching
- 10.6. Mathematics
- 10.7. Internet Access
- 10.8. Dates and Times
- 10.9. Data Compression
- 10.10. Performance Measurement
- 10.11. Quality Control
- 10.12. Batteries Included
- 11. Brief Tour of the Standard Library — Part II
- 12. Virtual Environments and Packages
- 13. What Now?
- 14. Interactive Input Editing and History Substitution
- 15. Floating Point Arithmetic: Issues and Limitations
- 16. 附录