Python Beginner's Guide¶
| Release: | 2.7.13 |
|---|---|
| Date: | Feb 13, 2017 |
Python is a simple, easy-to-learn yet powerful programming language. It has efficient high-level data structures and enables simple yet efficient object-oriented programming. Python's elegant syntax and dynamic typing, combined with its interpreted nature, make it an ideal language for scripting or developing applications in many fields on most platforms.
You can freely download from the official Python website: http://www.python.orgYou can obtain the Python interpreter and its standard extension libraries in source or binary form and freely distribute them. This site also provides a large number of third-party Python modules, programs, and tools, along with their additional documentation.
You can easily use C or C++ (or other languages callable from C) to extend the Python interpreter with new functions and data types. Python can also be used as an extension language for customized applications.
This manual informally introduces readers to the basic knowledge and concepts of the Python language and its related ecosystem. It is helpful to use the Python interpreter during learning and practice, but all examples are complete, so this manual can also be read offline.
For detailed information about related standard libraries or objects, please refer to Python Reference Documentation 。Python Reference Manual Provides more formal language-related specifications. If you want to write extensions in C or C++, please refer to Python Interpreter Extension and Integration Chapter And C API Reference Manual Of course, you can also read some books that introduce Python knowledge in depth.
This manual does not attempt to cover all of Python's knowledge and every feature, nor does it even cover all commonly used features. Rather, it introduces many of Python's most striking features and gives you an understanding of the language's characteristics and style. After reading it, you will be able to read and write Python modules or programs, and to use them later. Python Reference Manual Be prepared to continue learning many Python module libraries.
Glossary Also worth browsing.
- 1. Appetizers
- 2. Using the Python Interpreter
- 2.1. Invoking the Python Interpreter
- 2.1.1. Parameter Passing
- 2.1.2. Interactive Mode
- 2.2. The Interpreter and Its Environment
- 2.2.1. Source Code Encoding
- 2.1. Invoking the Python Interpreter
- 3. Python Introduction
- 3.1. Using Python as a Calculator
- 3.1.1. Numbers
- 3.1.2. Strings
- 3.1.3. About Unicode
- 3.1.4. Lists
- 3.2. The First Step of Programming
- 3.1. Using Python as a Calculator
- 4. Deep Dive into Python Control Flow
- 4.1. if Statements
- 4.2. for Statement
- 4.3. range() Function
- 4.4. break and continue statements, and the else clause in loops
- 4.5. pass Statement
- 4.6. Defining functions
- 4.7. Deep Dive into Python Function Definitions
- 4.7.1. Default Parameter Values
- 4.7.2. Keyword Arguments
- 4.7.3. Variable-length Argument Lists
- 4.7.4. Splitting Parameter Lists
- 4.7.5. Lambda Forms
- 4.7.6. Documentation Strings
- 4.8. Interlude: Coding Style
- 5. Data Structures
- 5.1. More About Lists
- 5.1.1. Using Linked Lists as Stacks
- 5.1.2. Using Linked Lists as Queues
- 5.1.3. Functional Programming Tools
- 5.1.4. List Comprehensions
- 5.1.4.1. Nested List Comprehensions
- 5.2. del Statement
- 5.3. Tuples and Sequences
- 5.4. Sets
- 5.5. Dictionaries
- 5.6. Looping techniques
- 5.7. In-depth Conditional Control
- 5.8. Comparing Sequences and Other Types
- 5.1. More About Lists
- 6. Module
- 6.1. More on modules
- 6.1.1. Executing Modules as Scripts
- 6.1.2. Module Search Path
- 6.1.3. "Compiled" Python Files
- 6.2. Standard modules
- 6.3. dir() Function
- 6.4. Packages
- 6.4.1. Importing * From a Package
- 6.4.2. References Within a Package
- 6.4.3. Packages in Multiple Directories
- 6.1. More on modules
- 7. Input and Output
- 7.1. Formatted Output
- 7.1.1. Old-Style String Formatting
- 7.2. Reading and writing files
- 7.2.1. File Object Methods
- 7.2.2. Using JSON to Store Structured Data
- 7.1. Formatted Output
- 8. Errors and Exceptions
- 8.1. Syntax errors
- 8.2. Exceptions
- 8.3. Handling exceptions
- 8.4. Raising exceptions
- 8.5. User-Defined Exceptions
- 8.6. Defining Cleanup Behavior
- 8.7. Predefined Clean-up Actions
- 9. Classes
- 9.1. Terminology
- 9.2. Python Scope and Namespaces
- 9.3. First Look at Classes
- 9.3.1. Class Definition Syntax
- 9.3.2. Class Objects
- 9.3.3. Instance Objects
- 9.3.4. Method Objects
- 9.3.5. Class and Instance Variables
- 9.4. Some remarks
- 9.5. Inheritance
- 9.5.1. Multiple Inheritance
- 9.6. Private Variables and Class-Local References
- 9.7. Supplement
- 9.8. Exceptions Are Classes Too
- 9.9. Iterators
- 9.10. Generators
- 9.11. Generator Expressions
- 10. Overview of the Python Standard Library
- 10.1. Operating System Interface
- 10.2. File Wildcards
- 10.3. Command Line Arguments
- 10.4. Redirection of Error Output and Program Termination
- 10.5. String Regular Expression Matching
- 10.6. Mathematics
- 10.7. Internet Access
- 10.8. Date and Time
- 10.9. Data Compression
- 10.10. Performance Metrics
- 10.11. Quality Control
- 10.12. "Swiss Army Knife"
- 11. Standard Library Tour – Part II
- 11.1. Output Format
- 11.2. Templates
- 11.3. Using Binary Data for Record Layouts
- 11.4. Multithreading
- 11.5. Logging
- 11.6. Weak references
- 11.7. List Tools
- 11.8. Decimal Floating-Point Arithmetic
- 12. What's Next?
- 13. Interactive Input Line Editing and History Recall
- 13.1. Line editing
- 13.2. History
- 13.3. Keyboard Shortcut Bindings
- 13.4. Other Interactive Interpreters
- 14. Floating Point Arithmetic: Issues and Limitations
- 14.1. Representation Errors
- 15. Appendix
- 15.1. Interactive Mode
- 15.1.1. Error Handling
- 15.1.2. Executing Python Scripts
- 15.1.3. Interactive Execution of Files
- 15.1.4. Customizing Modules
- 15.1. Interactive Mode