Python3虚拟环境构建

以Debian/Ubuntu系统举例说明如何配置 Python3 虚拟环境

2026-01-22 15:43 CST  · 1136 words  · 3 min

FastAPI后台开发基础(1):框架简介

特点 高性能:基于 Starlette 和 Pydantic,FastAPI 在性能上接近 Node.js 和 Go。 自动生成文档:内置 Swagger UI 和 ReDoc,可以自动生成交互式API文档。 类型安全:使用 Python 的类型提示,提供数据验证和序列化。 异步支持:原生支持异步编程,适合处理高并发请求。 最小化代码结构 1 2 3 4 5 6 7 8 9 from __future__ import annotations from fastapi import FastAPI app = FastAPI() @app.get("/") async def read_root(): return {"message": "Hello, World!"} 服务启动方式 fastapi 开发模式 fastapi dev main.py --host 0.0.0.0 --port 18888 ...

2025-12-30 09:12 CST  · 327 words  · 1 min

Python3 MRO链在super调用中的作用

简单的super类使用 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class A(object): def __init__(self): print(self.__class__, 'A init') class B1(A): def __init__(self): # 效果等同于 super(B1, self).__init__() # 参考 class B2 super().__init__() print(self.__class__, 'B1 init') if __name__ == '__main__': print(B1.mro()) B1() 代码运行的效果: 单继承时 super 调用的效果 此时对 B1 来说,它的 mro 调用链是:B1 –> A –> object ...

2025-12-26 19:31 CST  · 1826 words  · 4 min

关于Python3 MRO的笔记

MRO 的全称是:Method Resolution Order,从 Python2.3 开始,Python 使用 C3 算法来实现 Python 类继承时的线性解析逻辑。 Python 使用 C3 作为 MRO 算法的起因 C3 算法主要解决的问题 ...

2025-12-26 19:28 CST  · 1159 words  · 3 min
文章 Posts 分类 Categories 标签 Tags