diff --git a/docs/zh-hant/docs/index.md b/docs/zh-hant/docs/index.md
index 1111d427ce..e2e6c1e8a2 100644
--- a/docs/zh-hant/docs/index.md
+++ b/docs/zh-hant/docs/index.md
@@ -5,10 +5,10 @@
@@ -161,8 +161,6 @@ $ pip install "fastapi[standard]"
建立一個檔案 `main.py`,內容如下:
```Python
-from typing import Union
-
from fastapi import FastAPI
app = FastAPI()
@@ -174,7 +172,7 @@ def read_root():
@app.get("/items/{item_id}")
-def read_item(item_id: int, q: Union[str, None] = None):
+def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
```
@@ -183,9 +181,7 @@ def read_item(item_id: int, q: Union[str, None] = None):
如果你的程式使用 `async` / `await`,請使用 `async def`:
-```Python hl_lines="9 14"
-from typing import Union
-
+```Python hl_lines="7 12"
from fastapi import FastAPI
app = FastAPI()
@@ -197,13 +193,13 @@ async def read_root():
@app.get("/items/{item_id}")
-async def read_item(item_id: int, q: Union[str, None] = None):
+async def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
```
**注意**:
-如果你不確定,請查看文件中 _"In a hurry?"_ 章節關於
`async` 和 `await` 的說明。
+如果你不確定,請查看文件中 _"In a hurry?"_ 章節關於
`async` 和 `await` 的說明。
@@ -245,7 +241,7 @@ INFO: Application startup complete.
預設情況下,`fastapi dev` 會啟用自動重新載入,方便本機開發。
-你可以在
FastAPI CLI 文件 了解更多。
+你可以在
FastAPI CLI 文件 了解更多。
@@ -288,9 +284,7 @@ INFO: Application startup complete.
藉由 Pydantic,你可以使用標準 Python 型別來宣告 body。
-```Python hl_lines="4 9-12 25-27"
-from typing import Union
-
+```Python hl_lines="2 7-10 23-25"
from fastapi import FastAPI
from pydantic import BaseModel
@@ -300,7 +294,7 @@ app = FastAPI()
class Item(BaseModel):
name: str
price: float
- is_offer: Union[bool, None] = None
+ is_offer: bool | None = None
@app.get("/")
@@ -309,7 +303,7 @@ def read_root():
@app.get("/items/{item_id}")
-def read_item(item_id: int, q: Union[str, None] = None):
+def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
@@ -369,12 +363,12 @@ item: Item
...透過這一次宣告,你將獲得:
* 編輯器支援,包含:
- * 自動補全。
+ * Completion。
* 型別檢查。
* 資料驗證:
* 當資料無效時,自動且清楚地回報錯誤。
* 即使是深層巢狀的 JSON 物件也能驗證。
-*
Conversion輸入資料:將來自網路的資料轉換為 Python 資料與型別。可從以下讀取:
+*
Conversion輸入資料:將來自網路的資料轉換為 Python 資料與型別。可從以下讀取:
* JSON。
* 路徑參數。
* 查詢參數。
@@ -382,7 +376,7 @@ item: Item
* Headers。
* Forms。
* Files。
-*
Conversion輸出資料:將 Python 資料與型別轉換為網路資料(JSON):
+*
Conversion輸出資料:將 Python 資料與型別轉換為網路資料(JSON):
* 轉換 Python 型別(`str`、`int`、`float`、`bool`、`list` 等)。
* `datetime` 物件。
* `UUID` 物件。
@@ -445,7 +439,7 @@ item: Item
* 從不同位置宣告**參數**,例如:**headers**、**cookies**、**form 欄位**和**檔案**。
* 如何設定 **驗證限制**,例如 `maximum_length` 或 `regex`。
-* 強大且易用的 **
Dependency Injection** 系統。
+* 強大且易用的 **
Dependency Injection** 系統。
* 安全性與身份驗證,包含支援 **OAuth2**、**JWT tokens** 與 **HTTP Basic** 驗證。
* 更進階(但同樣簡單)的技巧,用於宣告**深層巢狀的 JSON models**(歸功於 Pydantic)。
* 與
Strawberry 及其他函式庫的 **GraphQL** 整合。
@@ -458,7 +452,7 @@ item: Item
### 部署你的 app(可選) { #deploy-your-app-optional }
-你也可以選擇將 FastAPI app 部署到
FastAPI Cloud;如果你還沒加入候補名單,可以前往加入。 🚀
+你也可以選擇將 FastAPI app 部署到
FastAPI Cloud,如果你還沒加入候補名單,請前往加入。 🚀
如果你已經有 **FastAPI Cloud** 帳號(我們已從候補名單邀請你 😉),你可以用一個指令部署你的應用程式。
@@ -530,7 +524,7 @@ FastAPI 依賴 Pydantic 與 Starlette。
*
httpx - 若你想使用 `TestClient`,則必須安裝。
*
jinja2 - 若你想使用預設的 template 設定,則必須安裝。
-*
python-multipart - 若你想透過 `request.form()` 支援表單
"parsing",則必須安裝。
+*
python-multipart - 若你想透過 `request.form()` 支援表單
"parsing",則必須安裝。
由 FastAPI 使用: