pip更改国内源
正常的install命令后添加
-i https://pypi.tuna.tsinghua.edu.cn/simple
Pyenv安装——windows
pip install pyenv-win –target D:\pyenv.pyenv
设置path环境变量 /bin何/shims
python利器——pipenv和pyenv介绍
https://www.jianshu.com/p/91269d686cf3
https://zhuanlan.zhihu.com/p/104935266
pipenv常用命令一览:
1 pipenv –where 列出本地工程路径
2 pipenv –venv 列出虚拟环境路径
3 pipenv –py 列出虚拟环境的Python可执行文件
4 pipenv install 安装包(创建虚拟环境)
5 pipenv install moduel –dev 在开发环境安装包
6 pipenv graph 查看包依赖
7 pipenv lock 生成lockfile
8 pipenv install –dev 安装所有开发环境包
9 pipenv uninstall –all 卸载所有包
10 pipenv –rm 删除虚拟环境
11 pipenv run python xxx.py 虚拟环境运行python
12 pipenv –rm 删除虚拟环境
13 pipenv uninstall 包名 删除部分包
Uvicron 基本了解
https://www.jianshu.com/p/175b4267e40f
uvicron有两种运行方式
第一种是代码式
import uvicorn
uvicorn.run(app, host=”127.0.0.1″, port=8000)
第二种是命令式
uvicorn 模块名:app –port=8000 –host=127.0.0.1
eg:
uvicorn app.main:app –reload
获取变量a类型:
type(a)
抛异常:
raise Exception
实例.调用不加括号时,可以调用方法也可以调用属性,如果重名,按照覆盖规则调最后声明的(方法只要名字一样,无论参数,都会覆盖)
lambda表达式(小的匿名函数):***
x = lambda a : a + 10
print(x(5))
//15
声明出入参类型:
def func(arg1:int,arg2:str) -> str:
return ‘some str’
FastAPI 支持在依赖项返回后执行一些额外的步骤
但需要用 yield 代替 return 来达到这一目的
.pyi 是对.py文件中方法的约束规则
https://cloud.tencent.com/developer/article/1882548
FastApi中Query在入参中会返回default为参数默认值, …表示参数必穿,
可以加强对参数的校验
快速搭建http服务器
python3 -m http.server 8000