[互联网]python_tutorial

上传人:jiups****uk12 文档编号:39144583 上传时间:2018-05-12 格式:PDF 页数:100 大小:295.07KB
返回 下载 相关 举报
[互联网]python_tutorial_第1页
第1页 / 共100页
[互联网]python_tutorial_第2页
第2页 / 共100页
[互联网]python_tutorial_第3页
第3页 / 共100页
[互联网]python_tutorial_第4页
第4页 / 共100页
[互联网]python_tutorial_第5页
第5页 / 共100页
点击查看更多>>
资源描述

《[互联网]python_tutorial》由会员分享,可在线阅读,更多相关《[互联网]python_tutorial(100页珍藏版)》请在金锄头文库上搜索。

1、Python TutorialRelease 2.3.3Guido van Rossum Fred L. Drake, Jr., editorDecember 19, 2003PythonLabs Email:docspython.orgCopyright c ? 2001, 2002, 2003 Python Software Foundation. All rights reserved.Copyright c ? 2000 BeO. All rights reserved.Copyright c ? 1995-2000 Corporation for National Research

2、Initiatives. All rights reserved.Copyright c ? 1991-1995 Stichting Mathematisch Centrum. All rights reserved.See the end of this document for complete license and permissions information.AbstractPython is an easy to learn, powerful programming language. It has efficient high-level data structures an

3、d a simple but effective approach to object-oriented programming. Pythons elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.The Python interpreter and the extensive standa

4、rd library are freely available in source or binary form for all major platforms from the Python Web site,http:/www.python.org/, and can be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional docume

5、ntation.The Python interpreter is easily extended with new functions and data types implemented in C or C+ (or other languages callable from C). Python is also suitable as an extension language for customizable applications.ThistutorialintroducesthereaderinformallytothebasicconceptsandfeaturesoftheP

6、ythonlanguageandsystem. It helps to have a Python interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well.For a description of standard objects and modules, see the Python Library Reference document. The PythonReference Manual give

7、s a more formal definition of the language. To write extensions in C or C+, read Extending and Embedding the Python Interpreter and Python/C API Reference. There are also several books covering Python in depth.This tutorial does not attempt to be comprehensive and cover every single feature, or even

8、 every commonly used feature. Instead, it introduces many of Pythons most noteworthy features, and will give you a good idea of thelanguages flavor and style. After reading it, you will be able to read and write Python modules and programs, and you will be ready to learn more about the various Pytho

9、n library modules described in the Python Library Reference.CONTENTS1Whetting Your Appetite12Using the Python Interpreter3 2.1Invoking the Interpreter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 2.2The Interpreter and Its Environment. . . . . . . . . . . . . . . . .

10、 . . . . . . . . . . . . . . .43An Informal Introduction to Python7 3.1Using Python as a Calculator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 3.2First Steps Towards Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164More Control Flow Tools

11、19 4.1if Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 4.2for Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 4.3The range() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

12、. . . . . . . .20 4.4break and continue Statements, and else Clauses on Loops . . . . . . . . . . . . . . . . .20 4.5pass Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 4.6Defining Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13、 . . . . . . . . . .21 4.7More on Defining Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235Data Structures27 5.1More on Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 5.2The del statement. . . . . . . . . . . . . .

14、 . . . . . . . . . . . . . . . . . . . . . . . . . . .31 5.3Tuples and Sequences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 5.4Dictionaries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 5.5Looping Techniques . . . . .

15、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 5.6More on Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 5.7Comparing Sequences and Other Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356Modules37 6.1More

16、 on Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 6.2Standard Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 6.3The dir() Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 6.4Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .417Input and Output45 7.1Fancier Output Formatting. . . . . . . . . . . . .

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号