- Sort Score
- Num 10 results
- Language All
Results 131 - 140 of 402 for item_2 (0.04 seconds)
-
docs/zh-hant/docs/python-types.md
/// info | 資訊 方括號裡的那些內部型別稱為「型別參數」。 在這個例子中,`str` 是傳給 `list` 的型別參數。 /// 這表示:「變數 `items` 是一個 `list`,而這個清單中的每個元素都是 `str`」。 這麼做之後,你的編輯器甚至在處理清單裡的項目時也能提供支援: <img src="/img/python-types/image05.png"> 沒有型別時,幾乎不可能做到這點。 請注意,變數 `item` 是清單 `items` 中的一個元素。 即便如此,編輯器仍然知道它是 `str`,並提供相應的支援。 #### Tuple 與 Set { #tuple-and-set } 你也可以用相同方式來宣告 `tuple` 與 `set`:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 10.7K bytes - Click Count (0) -
docs_src/dependencies/tutorial008b_an_py310.py
@app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): if item_id not in data: raise HTTPException(status_code=404, detail="Item not found") item = data[item_id] if item["owner"] != username: raise OwnerError(username)
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 775 bytes - Click Count (0) -
docs/fr/docs/index.md
app = FastAPI() class Item(BaseModel): name: str price: float is_offer: bool | None = None @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, q: str | None = None): return {"item_id": item_id, "q": q} @app.put("/items/{item_id}") def update_item(item_id: int, item: Item):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 19 18:37:13 GMT 2026 - 23.8K bytes - Click Count (0) -
docs_src/schema_extra_example/tutorial005_an_py310.py
from fastapi import Body, FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None @app.put("/items/{item_id}") async def update_item( *, item_id: int, item: Annotated[ Item, Body( openapi_examples={ "normal": {
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Aug 26 18:03:13 GMT 2023 - 1.5K bytes - Click Count (0) -
docs_src/app_testing/tutorial004_py310.py
from fastapi.testclient import TestClient items = {} @asynccontextmanager async def lifespan(app: FastAPI): items["foo"] = {"name": "Fighters"} items["bar"] = {"name": "Tenders"} yield # clean up items items.clear() app = FastAPI(lifespan=lifespan) @app.get("/items/{item_id}") async def read_items(item_id: str): return items[item_id] def test_read_items():Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 1.2K bytes - Click Count (0) -
docs_src/app_testing/app_b_py310/main.py
return fake_db[item_id] @app.post("/items/") async def create_item(item: Item, x_token: str = Header()) -> Item: if x_token != fake_secret_token: raise HTTPException(status_code=400, detail="Invalid X-Token header") if item.id in fake_db: raise HTTPException(status_code=409, detail="Item already exists") fake_db[item.id] = item.model_dump()
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Feb 04 13:32:24 GMT 2026 - 1.1K bytes - Click Count (0) -
README.md
app = FastAPI() class Item(BaseModel): name: str price: float is_offer: bool | None = None @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, q: str | None = None): return {"item_id": item_id, "q": q} @app.put("/items/{item_id}") def update_item(item_id: int, item: Item):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Mar 07 09:29:03 GMT 2026 - 24.3K bytes - Click Count (0) -
docs/zh-hant/docs/index.md
使用瀏覽器開啟 [http://127.0.0.1:8000/items/5?q=somequery](http://127.0.0.1:8000/items/5?q=somequery)。 你將會看到以下 JSON 回應: ```JSON {"item_id": 5, "q": "somequery"} ``` 你已經建立了一個具有以下功能的 API: * 透過路徑 `/` 和 `/items/{item_id}` 接受 HTTP 請求。 * 以上兩個路徑都接受 `GET` 操作(也被稱為 HTTP _方法_)。 * 路徑 `/items/{item_id}` 有一個 `int` 型別的路徑參數 `item_id`。 * 路徑 `/items/{item_id}` 有一個可選的 `str` 查詢參數 `q`。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 20.8K bytes - Click Count (0) -
fastapi/exceptions.py
```python from fastapi import FastAPI, HTTPException app = FastAPI() items = {"foo": "The Foo Wrestlers"} @app.get("/items/{item_id}") async def read_item(item_id: str): if item_id not in items: raise HTTPException(status_code=404, detail="Item not found") return {"item": items[item_id]} ``` """ def __init__( self, status_code: Annotated[Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Feb 11 18:41:21 GMT 2026 - 7.3K bytes - Click Count (0) -
docs_src/query_params_str_validations/tutorial001_py310.py
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Jan 07 14:11:31 GMT 2022 - 239 bytes - Click Count (0)