Error in user YAML: (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1
---
- oeasy Python 0616
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
本教程同步发布在:
个人网站: `https://oeasy.org`
蓝桥云课: `https://www.lanqiao.cn/courses/3584`
GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
Gitee: `https://gitee.com/overmind1980/oeasypython`
---- 上次我们添加了一种请求方法PUT
- 跑是能跑起来
- 但是有些不清楚的地方
@app.get("/")
async def read_root():
return {"Hello": "World"}
- 这个函数到底什么意思?
- 我们从头来分析
- 从FastAPI这个包中
- 引入fastapi这个类
- FastAPI 是 Starlette的派生类
- 可以使用Starlette中的方法
- Starlette是我们的web框架
- main.py中的app
- 其实对应了shell中的命令
- uvicorn main:app --reload
- 使用的方法是get方法
- get的路径是/
- async 的意思是异步等待
- 没有响应结果他会去服务下一个请求
- 有了结果再给过去
- 返回的类型
- 字典
- 列表
- 字符串
- 数字
- 这里理解了整个函数的结构
- 从导入
- 到实例化
- 再到函数修饰器
- 函数定义
- 函数返回值
- 对于根下的访问我们了解了
- 对于具体路径的访问是如何的呢?🤔
- 下次再说👋
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。





