👉 项目官网:https://www.python-office.com/ 👈

👉 本开源项目的交流群 👈

github star gitee star atomgit star

AI编程 AI交流群

大家好,这里是程序员晚枫,正在all in AI编程实战,全网同名。

(直播 30 min,录播可 1.5× 观看)

──────────────────
0.1 开场 2 min
“如果第 0 讲就翻车,后面 10 讲都会变成灾难。”
目标:所有人能在本地 10 分钟内跑通“Hello Iterator”,并学会把代码一键格式化成 PEP 8。

──────────────────
0.2 环境三件套:pyenv + virtualenv + poetry(10 min)
• macOS / Linux

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
brew install pyenv
pyenv install 3.12.2
pyenv global 3.12.2
pip install poetry
poetry new py_adv_course && cd py_adv_course
poetry add rich pytest ipython --group dev
```
• Windows (PowerShell)
```powershell
winget install Python.Python.3.12
pip install poetry
poetry init --no-interaction
poetry add rich pytest ipython --group dev
```
现场验证:
```bash
poetry run python -c "import rich, sys; print(sys.version)"

──────────────────
0.3 Git 工作流 5 min
• 分支策略:main 保护 + feat/lesson-0 写代码
• commit message 模板:

1
2
3
4
5
6
7
<type>: <subject>
<body>
Closes #issue
```
• 课堂仓库已放 `.gitmessage` 模板,一条命令激活:
```bash
git config commit.template .gitmessage

──────────────────
0.4 代码风格一键三连(black + isort + flake8) 5 min

1
2
3
4
5
# pyproject.toml 片段
[tool.black]
line-length = 88
[tool.isort]
profile = "black"

演示:

1
2
3
poetry run black .
poetry run isort .
poetry run flake8 .

──────────────────
0.5 IDE 隐藏技巧 5 min
• VS Code
– Remote-Containers:一键进入 Poetry 容器
– Postfix 模板:for + Tab 生成迭代器循环
• PyCharm
– “Attach to Process” 调试运行中的生成器
– 运行配置模板:自动激活 Poetry 虚拟环境

──────────────────
0.6 课前小测 2 min
在终端执行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
poetry run pytest tests/test_lesson0.py -q
```
全绿即通关;失败截图发到群,助教 24 h 内答疑。

──────────────────
0.7 资料速查表
• 课程仓库:`https://github.com/course/py-advanced`
• 课件下载:`slides/L0_setup.pdf`
• 文档索引:`docs/setup.md`(含常见报错 FAQ)

──────────────────
0.8 彩蛋:一条命令更新全部工具
```bash
poetry up # 一键更新 lock 文件并安装

(完)


大家在学习课程中有任何问题,欢迎+微信和我交流👉我的联系方式:微信、读者群、1对1、福利

扫一扫,领红包

美团红包

程序员晚枫专注AI编程培训,小白看完他和图灵社区合作的教程《30讲 · AI编程训练营》就能上手做AI项目。

🎓 AI 编程实战课程

想系统学习 AI 编程?程序员晚枫的 AI 编程实战课 帮你从零上手!