explaingit

xianhu/learnpython

8,434Jupyter NotebookAudience · developerComplexity · 1/5Setup · easy

TLDR

A Chinese-language Python learning resource with runnable code examples and Jupyter notebooks covering beginner through intermediate topics, from basic syntax to async programming and mini-projects.

Mindmap

mindmap
  root((learnpython))
    Beginner Topics
      Python basics
      Matplotlib charts
      Web crawling
    Intermediate Topics
      Decorators
      Async programming
      Metaclasses
    Practical Tasks
      Email automation
      Flask REST API
      Redis messaging
    Projects
      WeChat bot
      Text generation
      Data visualization
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Learn Python concepts like decorators, coroutines, or metaclasses by reading and running short focused code examples.

USE CASE 2

Copy and adapt the web crawler example to scrape a website using the Requests library.

USE CASE 3

Use the Flask REST API example as a starting point for building a simple Python web service.

USE CASE 4

Study the email automation and CSV file handling examples to automate routine data tasks in Python.

Tech stack

PythonJupyter Notebook

Getting it running

Difficulty · easy Time to first run · 5min

README and code comments are written in Chinese, non-Chinese readers may need translation tools.

In plain English

LearnPython is a Chinese-language collection of Python code examples intended for people learning the language. The repository description translates to "Learn Python in the form of code", and the project links to a Zhihu column (Zhihu is a Chinese question-and-answer platform, similar to Quora) where the author writes accompanying explanations. The repository is organized as a set of Python files and Jupyter notebooks, each focused on a specific topic. The files cover a wide range across beginner and intermediate territory. Beginner entries include a thousand-line introduction to Python basics, an introduction to Matplotlib for drawing charts and animations, and a simple web crawler using the Requests library. More advanced entries cover functional programming, Python decorators (a way to modify how functions behave), coroutines and asynchronous programming, metaclasses, and multi-threading versus multi-processing. Several files focus on practical tasks: sending automated emails, reading and writing CSV files, working with Redis (a type of database used for fast message passing), scheduling recurring tasks, and building a simple RESTful API using Flask (a lightweight Python web framework). There are also entries on SQLAlchemy (a library for interacting with databases), regular expressions for text matching, and socket programming for network communication. The collection also includes a few project-style files that go beyond syntax tutorials, such as one that builds a WeChat assistant bot, one that generates text using a Markov chain model, and one that visualizes topic relationships from Zhihu data. A Plotly directory contains charting examples written in Jupyter notebooks. The README is written entirely in Chinese. Contributions via pull request are welcome according to the project notes.

Copy-paste prompts

Prompt 1
Using the style of xianhu's LearnPython examples, write a Python script that crawls a web page and saves all image URLs to a CSV file.
Prompt 2
Explain Python decorators with a simple working example in this tutorial collection's style, wrap a function to log its execution time.
Prompt 3
Show me a minimal Flask REST API in Python that reads from a SQLite database using SQLAlchemy, following this collection's concise tutorial style.
Prompt 4
Write a Python async example that fetches multiple URLs concurrently using asyncio, in the style of the async programming tutorial in this repo.
Open on GitHub → Explain another repo

← xianhu on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.