mirror of https://github.com/tiangolo/fastapi.git
🌐 Update Chinese translation for `docs/zh/docs/tutorial/query-params.md` (#11557)
This commit is contained in:
parent
35fcb31dca
commit
abe62d8a81
|
|
@ -92,9 +92,19 @@ http://127.0.0.1:8000/items/?skip=20
|
|||
|
||||
参数还可以声明为 `bool` 类型,FastAPI 会自动转换参数类型:
|
||||
|
||||
```Python hl_lines="9"
|
||||
{!../../../docs_src/query_params/tutorial003.py!}
|
||||
```
|
||||
|
||||
=== "Python 3.10+"
|
||||
|
||||
```Python hl_lines="7"
|
||||
{!> ../../../docs_src/query_params/tutorial003_py310.py!}
|
||||
```
|
||||
|
||||
=== "Python 3.8+"
|
||||
|
||||
```Python hl_lines="9"
|
||||
{!> ../../../docs_src/query_params/tutorial003.py!}
|
||||
```
|
||||
|
||||
|
||||
本例中,访问:
|
||||
|
||||
|
|
@ -137,9 +147,18 @@ http://127.0.0.1:8000/items/foo?short=yes
|
|||
|
||||
FastAPI 通过参数名进行检测:
|
||||
|
||||
```Python hl_lines="8 10"
|
||||
{!../../../docs_src/query_params/tutorial004.py!}
|
||||
```
|
||||
=== "Python 3.10+"
|
||||
|
||||
```Python hl_lines="6 8"
|
||||
{!> ../../../docs_src/query_params/tutorial004_py310.py!}
|
||||
```
|
||||
|
||||
=== "Python 3.8+"
|
||||
|
||||
```Python hl_lines="8 10"
|
||||
{!> ../../../docs_src/query_params/tutorial004.py!}
|
||||
```
|
||||
|
||||
|
||||
## 必选查询参数
|
||||
|
||||
|
|
@ -195,9 +214,17 @@ http://127.0.0.1:8000/items/foo-item?needy=sooooneedy
|
|||
|
||||
当然,把一些参数定义为必选,为另一些参数设置默认值,再把其它参数定义为可选,这些操作都是可以的:
|
||||
|
||||
```Python hl_lines="10"
|
||||
{!../../../docs_src/query_params/tutorial006.py!}
|
||||
```
|
||||
=== "Python 3.10+"
|
||||
|
||||
```Python hl_lines="8"
|
||||
{!> ../../../docs_src/query_params/tutorial006_py310.py!}
|
||||
```
|
||||
|
||||
=== "Python 3.8+"
|
||||
|
||||
```Python hl_lines="10"
|
||||
{!> ../../../docs_src/query_params/tutorial006.py!}
|
||||
```
|
||||
|
||||
本例中有 3 个查询参数:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue