摘要:
在 Python 中,使用 BaseModel(通常指 Pydantic 的 BaseModel)和普通的 Python class 主要区别在于数据验证、序列化和类型提示的能力。以下是它们的核心区别: 1. 普通 Python Class(不使用 BaseModel) python class P 阅读全文
posted @ 2025-07-18 17:55
daviyoung
阅读(70)
评论(0)
推荐(0)
摘要:
1、安装 pip install fastapi 2、新建main.py from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"} 3、运 阅读全文
posted @ 2025-07-18 17:31
daviyoung
阅读(8)
评论(0)
推荐(0)
摘要:
vs code中: 创建虚拟环境 python -m venv .venv 激活: .\.venv\Scripts\activate 激活虚拟环境后即可使用。 删除虚拟环境 # 先退出虚拟环境(如果已激活) deactivate # 删除虚拟环境目录 Remove-Item -Recurse -Fo 阅读全文
posted @ 2025-07-18 17:24
daviyoung
阅读(10)
评论(0)
推荐(0)
摘要:
FastAPI 的路由系统是其核心组件之一,负责将客户端请求(如 HTTP GET、POST 等)映射到具体的处理函数(也叫“视图函数”或“端点”)。下面是 FastAPI 路由相关的知识总结,涵盖基本使用、进阶功能、最佳实践等。 🧱 基础知识 1. 路由定义方式 from fastapi imp 阅读全文
posted @ 2025-07-18 17:09
daviyoung
阅读(76)
评论(0)
推荐(0)

浙公网安备 33010602011771号