第1周:Python基础 & 环境搭建
日期:2026-05-28 | 状态:完成
学习目标
- [x] 掌握Python基础(数据类型、函数、面向对象)
- [x] 搭建本地AI开发环境
- [ ] 跑通第一个LLM调用脚本
学习笔记
Python基础
# 列表推导式
squares = [x**2 for x in range(10)]
# 装饰器
def timer(func):
def wrapper(*args, **kwargs):
import time
start = time.time()
result = func(*args, **kwargs)
print(f"耗时: {time.time()-start:.2f}s")
return result
return wrapper
开发环境搭建
conda create -n aistudy python=3.11 -y
conda activate aistudy
pip install openai python-dotenv langchain chromadb flask
踩坑记录
| 问题 | 解决 |
|---|---|
| pip安装慢 | pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ |
| 虚拟环境版本不对 | 用conda指定版本 |