]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🌐 Update Chinese translation for `docs/zh/docs/tutorial/query-params.md` (#11557)
authorCAO Mingpei <caomingpei@outlook.com>
Sun, 4 Aug 2024 23:33:57 +0000 (07:33 +0800)
committerGitHub <noreply@github.com>
Sun, 4 Aug 2024 23:33:57 +0000 (18:33 -0500)
docs/zh/docs/tutorial/query-params.md

index 77138de510ff26814e7f27b73f4f6ce3f97c1845..8b2528c9a6a556be197660f5db3cb08f65890447 100644 (file)
@@ -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 个查询参数: