> For the complete documentation index, see [llms.txt](https://jarvisma.gitbook.io/pythonlearn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jarvisma.gitbook.io/pythonlearn/master.md).

# Introduction

Python 是一门非常容易上手的语言，通过查阅资料和教程，也许一晚上就能写出一个简单的爬虫。但 Python 也是一门很难精通的语言，因为简洁的语法背后隐藏了许多黑科技。本文主要针对的读者是：

1. 毫无 Python 经验的小白
2. 有一些简单 Python 经验。但只会复制粘贴代码，不知其所以然的读者
3. 觉得单独一篇文章太繁琐，质量没保证，却没空读完一本书，但又想对 Python 有全面了解的读者

当然，用一篇文章来讲完某个语言是不可能的事情，我希望读完本文的读者可以：

1. 对 Python 的整体知识结构形成初步概念
2. 了解 Python 特有的知识点，比如装饰器、上下文、生成器等等，不仅会写 Demo，还对背后的原理有一定了解
3. 避免 C++/Java 等风格的 Python 代码，能够写出地道的 Python 代码
4. 能够熟练的使用 Python 编写脚本实现日常的简单需求，能够维护小型 Python 项目，能够阅读比较复杂的 Python 源码

如果以上介绍符合你对自己的定位，在开始阅读之前，还需要明确几点：

1. 本文不会介绍用法，那样太肤浅
2. 本文不会深入介绍某个知识点，比如分析源码等，那样太啰嗦，我希望做一名引路人，描述各个知识点的概貌并略作引申，为读者指出下一步的研究方向
3. 代码注释非常重要，一定要看，几乎所有的代码都可以执行。强烈建议手敲一遍！

请不要在学习 Python2 还是 Python3 之间犹豫了，除非你很明确自己只接触 Python2，否则就从 Python3 学起，新版本的语言总是以为这进步和生产力（Swift 和 Xcode 除外）。Python 2 和 3 之间语法不兼容，但这并不影响熟悉 Python3 的开发者迅速写出 Python2 的代码，反之亦然、所以与其在反复纠结中浪费时间，不如立刻行动起来。

推荐使用 **CodeRunner** 来运行本文中的 demo，它比文本编辑器功能更强大，比如支持自动补全和断点调试，又比 Pycharm 轻量得多。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://jarvisma.gitbook.io/pythonlearn/master.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
