<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://www.zhuzhugst.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://www.zhuzhugst.com/feed.php">
        <title>张叶安的博客 - python</title>
        <description></description>
        <link>https://www.zhuzhugst.com/</link>
        <image rdf:resource="https://www.zhuzhugst.com/lib/exe/fetch.php?media=logo.png" />
       <dc:date>2026-04-23T04:16:39+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter44&amp;rev=1775717085&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter43&amp;rev=1775717063&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter42&amp;rev=1775717045&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter41&amp;rev=1775717025&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter40&amp;rev=1775717006&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter39&amp;rev=1775716988&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter38&amp;rev=1775716965&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter37&amp;rev=1775716947&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter36&amp;rev=1775716929&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter35&amp;rev=1775716910&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter34&amp;rev=1775716892&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter33&amp;rev=1775716874&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter32&amp;rev=1775716853&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter31&amp;rev=1775716761&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter30&amp;rev=1775716741&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter29&amp;rev=1775716721&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.zhuzhugst.com/doku.php?id=python:chapter28&amp;rev=1775716703&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://www.zhuzhugst.com/lib/exe/fetch.php?media=logo.png">
        <title>张叶安的博客</title>
        <link>https://www.zhuzhugst.com/</link>
        <url>https://www.zhuzhugst.com/lib/exe/fetch.php?media=logo.png</url>
    </image>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter44&amp;rev=1775717085&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:44:45+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter44 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter44&amp;rev=1775717085&amp;do=diff</link>
        <description>第四十四章：附录与资源

附录A：Python内置函数
 函数  描述 ------------ abs()  绝对值  all()  所有元素为真  any()  任一元素为真  bin()  转二进制字符串  bool()  转布尔值  chr()  ASCII码转字符  dict()</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter43&amp;rev=1775717063&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:44:23+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter43 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter43&amp;rev=1775717063&amp;do=diff</link>
        <description>第四十三章：性能优化

本章目标

完成本章学习后，你将能够：

	*  分析代码性能瓶颈
	*  使用高效的数据结构和算法
	*  使用Cython加速
	*  进行并发优化

性能分析


import cProfile
import pstats

# 分析代码
cProfile.run(&#039;my_function()&#039;, &#039;output.stats&#039;)

# 查看统计
p = pstats.Stats(&#039;output.stats&#039;)
p.sort_stats(&#039;cumulative&#039;).print_stats(10)</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter42&amp;rev=1775717045&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:44:05+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter42 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter42&amp;rev=1775717045&amp;do=diff</link>
        <description>第四十二章：项目结构

本章目标

完成本章学习后，你将能够：

	*  组织Python项目结构
	*  编写配置文件
	*  管理依赖
	*  发布项目到PyPI

项目结构


my_project/
├── src/
│   └── my_package/
│       ├── __init__.py
│       ├── module1.py
│       └── module2.py
├── tests/
│   ├── __init__.py
│   └── test_module1.py
├── docs/
├── .gitignore
├── LICENSE
├── README.md
├── pyproject.toml
└── requirements.txt…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter41&amp;rev=1775717025&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:43:45+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter41 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter41&amp;rev=1775717025&amp;do=diff</link>
        <description>第四十一章：测试与调试

本章目标

完成本章学习后，你将能够：

	*  编写单元测试
	*  使用pytest框架
	*  使用调试器
	*  进行性能分析

unittest模块


import unittest

def add(a, b):
    return a + b

class TestMath(unittest.TestCase):
    def test_add(self):
        self.assertEqual(add(2, 3), 5)
        self.assertEqual(add(-1, 1), 0)
    
    def test_add_type_error(self):
        with self.assertRaises(TypeError):
            add(&quot;a&quot;, 1)

if __name__ == &#039;__main__&#039;:
    unittest.main()…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter40&amp;rev=1775717006&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:43:26+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter40 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter40&amp;rev=1775717006&amp;do=diff</link>
        <description>第四十章：自动化脚本

本章目标

完成本章学习后，你将能够：

	*  自动化文件操作
	*  自动化系统任务
	*  处理Excel和PDF
	*  发送邮件通知

文件自动化


import os
import shutil
from pathlib import Path

# 批量重命名
for i, file in enumerate(os.listdir(&#039;.&#039;)):
    if file.endswith(&#039;.txt&#039;):
        os.rename(file, f&#039;doc_{i:03d}.txt&#039;)

# 按扩展名整理文件
for file in Path(&#039;.&#039;).iterdir():
    if file.is_file():
        ext = file.suffix[1:] or &#039;no_ext&#039;
        os.makedirs(ext, exist_ok=True)
        shutil.move(str(file), f&quot;{ext}/{file.name}&quot;)…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter39&amp;rev=1775716988&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:43:08+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter39 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter39&amp;rev=1775716988&amp;do=diff</link>
        <description>第三十九章：Web应用项目

本章目标

完成本章学习后，你将能够：

	*  设计Web应用架构
	*  实现用户认证
	*  集成数据库
	*  部署Web应用

项目结构


myapp/
├── app/
│   ├── __init__.py
│   ├── models.py
│   ├── views.py
│   ├── forms.py
│   └── templates/
├── config.py
├── requirements.txt
└── run.py</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter38&amp;rev=1775716965&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:42:45+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter38 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter38&amp;rev=1775716965&amp;do=diff</link>
        <description>第三十八章：数据分析项目

本章目标

完成本章学习后，你将能够：

	*  使用NumPy处理数值数据
	*  使用Pandas处理表格数据
	*  使用Matplotlib可视化
	*  完成完整数据分析流程

NumPy基础


import numpy as np

# 创建数组
arr = np.array([1, 2, 3, 4, 5])
matrix = np.array([[1, 2], [3, 4], [5, 6]])

# 特殊数组
zeros = np.zeros((3, 4))
ones = np.ones((2, 3))
identity = np.eye(3)

# 数组运算
arr + 10
arr * 2
np.sum(arr)
np.mean(arr)
np.std(arr)

# 索引和切片
arr[0]
matrix[0, 1]
matrix[:, 0]  # 第一列…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter37&amp;rev=1775716947&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:42:27+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter37 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter37&amp;rev=1775716947&amp;do=diff</link>
        <description>第三十七章：网络爬虫实战

本章目标

完成本章学习后，你将能够：

	*  使用requests获取网页
	*  使用BeautifulSoup解析HTML
	*  使用Scrapy框架
	*  处理反爬虫机制

Requests基础


import requests

# GET请求
response = requests.get(&#039;https://api.github.com&#039;)
print(response.status_code)
print(response.json())

# 带参数
params = {&#039;q&#039;: &#039;python&#039;, &#039;page&#039;: 1}
response = requests.get(&#039;https://api.github.com/search/repositories&#039;, params=params)

# POST请求
data = {&#039;key&#039;: &#039;value&#039;}
response = requests.post(&#039;https://httpbin.org/post&#039;, json=data)

# 设置Headers
headers = {&#039;Us…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter36&amp;rev=1775716929&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:42:09+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter36 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter36&amp;rev=1775716929&amp;do=diff</link>
        <description>第三十六章：Django Web开发

本章目标

完成本章学习后，你将能够：

	*  创建Django项目
	*  定义模型和视图
	*  使用Admin后台
	*  开发完整应用

快速开始

```bash
# 安装
pip install django

# 创建项目
django-admin startproject mysite</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter35&amp;rev=1775716910&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:41:50+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter35 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter35&amp;rev=1775716910&amp;do=diff</link>
        <description>第三十五章：Flask Web开发

本章目标

完成本章学习后，你将能够：

	*  创建Flask应用
	*  定义路由和视图
	*  处理请求和响应
	*  使用模板

快速开始


from flask import Flask, jsonify, request, render_template

app = Flask(__name__)

@app.route(&#039;/&#039;)
def hello():
    return &#039;Hello, World!&#039;

@app.route(&#039;/user/&lt;name&gt;&#039;)
def user(name):
    return f&#039;Hello, {name}!&#039;

@app.route(&#039;/api/data&#039;, methods=[&#039;GET&#039;, &#039;POST&#039;])
def data():
    if request.method == &#039;POST&#039;:
        data = request.json
        return jsonify({&#039;received&#039;: data}), 201
    return jsonify({&#039;m…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter34&amp;rev=1775716892&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:41:32+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter34 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter34&amp;rev=1775716892&amp;do=diff</link>
        <description>第三十四章：ORM与SQLAlchemy

本章目标

完成本章学习后，你将能够：

	*  理解ORM概念
	*  使用SQLAlchemy定义模型
	*  执行CRUD操作
	*  处理关系映射

SQLAlchemy基础


from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

Base = declarative_base()

# 定义模型
class User(Base):
    __tablename__ = &#039;users&#039;
    
    id = Column(Integer, primary_key=True)
    name = Column(String(50))
    email = Column(String(100))
    
    def __repr__(self):
      …</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter33&amp;rev=1775716874&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:41:14+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter33 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter33&amp;rev=1775716874&amp;do=diff</link>
        <description>第三十三章：MySQL数据库

本章目标

完成本章学习后，你将能够：

	*  使用pymysql连接MySQL
	*  执行增删改查
	*  使用连接池

基础操作


import pymysql

# 连接数据库
conn = pymysql.connect(
    host=&#039;localhost&#039;,
    user=&#039;user&#039;,
    password=&#039;password&#039;,
    database=&#039;mydb&#039;,
    charset=&#039;utf8mb4&#039;
)

try:
    with conn.cursor() as cursor:
        # 创建表
        cursor.execute(&#039;&#039;&#039;
            CREATE TABLE IF NOT EXISTS users (
                id INT AUTO_INCREMENT PRIMARY KEY,
                name VARCHAR(100),
                email VARCHAR(100)
       …</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter32&amp;rev=1775716853&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:40:53+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter32 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter32&amp;rev=1775716853&amp;do=diff</link>
        <description>第三十二章：SQLite数据库

本章目标

完成本章学习后，你将能够：

	*  使用sqlite3模块
	*  执行SQL语句
	*  处理事务
	*  防止SQL注入

基础操作


import sqlite3

# 连接数据库
conn = sqlite3.connect(&#039;example.db&#039;)
cursor = conn.cursor()

# 创建表
cursor.execute(&#039;&#039;&#039;
    CREATE TABLE IF NOT EXISTS users (
        id INTEGER PRIMARY KEY,
        name TEXT NOT NULL,
        email TEXT UNIQUE
    )
&#039;&#039;&#039;)

# 插入数据
cursor.execute(&quot;INSERT INTO users (name, email) VALUES (?, ?)&quot;,
               (&quot;Alice&quot;, &quot;alice@example.com&quot;))
conn.commit()

# 查询
cursor.execute(&quot;SELE…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter31&amp;rev=1775716761&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:39:21+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter31 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter31&amp;rev=1775716761&amp;do=diff</link>
        <description>第三十一章：并发模式与最佳实践

本章目标

完成本章学习后，你将能够：

	*  选择合适的并发模型
	*  避免常见并发陷阱
	*  优化并发性能

并发模型选择
 场景  推荐方案   I/O密集型，大量连接</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter30&amp;rev=1775716741&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:39:01+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter30 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter30&amp;rev=1775716741&amp;do=diff</link>
        <description>第三十章：异步编程

本章目标

完成本章学习后，你将能够：

	*  理解asyncio编程模型
	*  使用async/await
	*  创建和运行协程
	*  处理异步I/O

基础概念


import asyncio

async def hello():
    print(&quot;Hello&quot;)
    await asyncio.sleep(1)
    print(&quot;World&quot;)

# 运行
asyncio.run(hello())</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter29&amp;rev=1775716721&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:38:41+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter29 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter29&amp;rev=1775716721&amp;do=diff</link>
        <description>第二十九章：多进程

本章目标

完成本章学习后，你将能够：

	*  创建和管理进程
	*  进程间通信
	*  使用进程池
	*  理解进程vs线程

创建进程


import multiprocessing
import time

def worker(name):
    print(f&quot;Process {name} started&quot;)
    time.sleep(2)
    print(f&quot;Process {name} finished&quot;)

if __name__ == &#039;__main__&#039;:
    # 创建进程
    p1 = multiprocessing.Process(target=worker, args=(&quot;P1&quot;,))
    p2 = multiprocessing.Process(target=worker, args=(&quot;P2&quot;,))
    
    p1.start()
    p2.start()
    
    p1.join()
    p2.join()…</description>
    </item>
    <item rdf:about="https://www.zhuzhugst.com/doku.php?id=python:chapter28&amp;rev=1775716703&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2026-04-09T06:38:23+00:00</dc:date>
        <dc:creator>张叶安 (midas@undisclosed.example.com)</dc:creator>
        <title>chapter28 - 创建</title>
        <link>https://www.zhuzhugst.com/doku.php?id=python:chapter28&amp;rev=1775716703&amp;do=diff</link>
        <description>第二十八章：多线程

本章目标

完成本章学习后，你将能够：

	*  创建和管理线程
	*  理解GIL
	*  使用线程同步机制
	*  掌握线程池

创建线程


import threading
import time

def worker(name):
    print(f&quot;{name} started&quot;)
    time.sleep(2)
    print(f&quot;{name} finished&quot;)

# 创建线程
thread1 = threading.Thread(target=worker, args=(&quot;Thread-1&quot;,))
thread2 = threading.Thread(target=worker, args=(&quot;Thread-2&quot;,))

# 启动线程
thread1.start()
thread2.start()

# 等待完成
thread1.join()
thread2.join()…</description>
    </item>
</rdf:RDF>
