Search Options

Results per page
Sort
Preferred Languages
Advance

Results 51 - 60 of 266 for float (0.2 sec)

  1. docs_src/body_updates/tutorial001.py

    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: Union[str, None] = None
        description: Union[str, None] = None
        price: Union[float, None] = None
        tax: float = 10.5
        tags: List[str] = []
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
        "bar": {"name": "Bar", "description": "The bartenders", "price": 62, "tax": 20.2},
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 906 bytes
    - Viewed (0)
  2. docs_src/body_updates/tutorial002.py

    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: Union[str, None] = None
        description: Union[str, None] = None
        price: Union[float, None] = None
        tax: float = 10.5
        tags: List[str] = []
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
        "bar": {"name": "Bar", "description": "The bartenders", "price": 62, "tax": 20.2},
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 1K bytes
    - Viewed (0)
  3. docs/uk/docs/python-types.md

    Python підтримує додаткові "підказки типу" ("type hints") (також звані "анотаціями типу" ("type annotations")).
    
    Ці **"type hints"** є спеціальним синтаксисом, що дозволяє оголошувати <abbr title="наприклад: str, int, float, bool">тип</abbr> змінної.
    
    За допомогою оголошення типів для ваших змінних, редактори та інструменти можуть надати вам кращу підтримку.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 19.7K bytes
    - Viewed (0)
  4. docs/ja/docs/tutorial/extra-data-types.md

    # 追加データ型
    
    今までは、以下のような一般的なデータ型を使用してきました:
    
    * `int`
    * `float`
    * `str`
    * `bool`
    
    しかし、より複雑なデータ型を使用することもできます。
    
    そして、今まで見てきたのと同じ機能を持つことになります:
    
    * 素晴らしいエディタのサポート
    * 受信したリクエストからのデータ変換
    * レスポンスデータのデータ変換
    * データの検証
    * 自動注釈と文書化
    
    ## 他のデータ型
    
    ここでは、使用できる追加のデータ型のいくつかを紹介します:
    
    * `UUID`:
        * 多くのデータベースやシステムで共通のIDとして使用される、標準的な「ユニバーサルにユニークな識別子」です。
        * リクエストとレスポンスでは`str`として表現されます。
    * `datetime.datetime`:
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 3.2K bytes
    - Viewed (0)
  5. docs/en/docs/tutorial/path-params.md

          "url": "https://errors.pydantic.dev/2.1/v/int_parsing"
        }
      ]
    }
    ```
    
    because the path parameter `item_id` had a value of `"foo"`, which is not an `int`.
    
    The same error would appear if you provided a `float` instead of an `int`, as in: <a href="http://127.0.0.1:8000/items/4.2" class="external-link" target="_blank">http://127.0.0.1:8000/items/4.2</a>
    
    !!! check
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  6. docs/ru/docs/tutorial/path-params.md

                "type": "type_error.integer"
            }
        ]
    }
    ```
    
    из-за того, что параметр пути `item_id` имеет значение `"foo"`, которое не является типом  `int`.
    
    Та же ошибка возникнет, если вместо `int` передать `float` , например: <a href="http://127.0.0.1:8000/items/4.2" class="external-link" target="_blank">http://127.0.0.1:8000/items/4.2</a>
    
    !!! check "Заметка"
        **FastAPI** обеспечивает проверку типов, используя всё те же определения типов.
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 14.1K bytes
    - Viewed (0)
  7. docs/zh/docs/tutorial/path-params.md

                ],
                "msg": "value is not a valid integer",
                "type": "type_error.integer"
            }
        ]
    }
    ```
    
    这是因为路径参数 `item_id` 的值 (`"foo"`)的类型不是 `int`。
    
    值的类型不是 `int ` 而是浮点数(`float`)时也会显示同样的错误,比如: <a href="http://127.0.0.1:8000/items/4.2" class="external-link" target="_blank">http://127.0.0.1:8000/items/4.2。</a>
    
    !!! check "检查"
    
        **FastAPI** 使用 Python 类型声明实现了数据校验。
    
        注意,上面的错误清晰地指出了未通过校验的具体原因。
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Apr 01 05:35:40 GMT 2024
    - 7.6K bytes
    - Viewed (0)
  8. tests/test_request_body_parameters_media_type.py

    media_type = "application/vnd.api+json"
    
    
    # NOTE: These are not valid JSON:API resources
    # but they are fine for testing requestBody with custom media_type
    class Product(BaseModel):
        name: str
        price: float
    
    
    class Shop(BaseModel):
        name: str
    
    
    @app.post("/products")
    async def create_product(data: Product = Body(media_type=media_type, embed=True)):
        pass  # pragma: no cover
    
    
    @app.post("/shops")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 6.4K bytes
    - Viewed (0)
  9. docs/zh/docs/tutorial/response-model.md

    ## 响应模型编码参数
    
    你的响应模型可以具有默认值,例如:
    
    ```Python hl_lines="11  13-14"
    {!../../../docs_src/response_model/tutorial004.py!}
    ```
    
    * `description: Union[str, None] = None` 具有默认值 `None`。
    * `tax: float = 10.5` 具有默认值 `10.5`.
    * `tags: List[str] = []` 具有一个空列表作为默认值: `[]`.
    
    但如果它们并没有存储实际的值,你可能想从结果中忽略它们的默认值。
    
    举个例子,当你在 NoSQL 数据库中保存了具有许多可选属性的模型,但你又不想发送充满默认值的很长的 JSON 响应。
    
    ### 使用 `response_model_exclude_unset` 参数
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 7.9K bytes
    - Viewed (0)
  10. docs_src/extra_models/tutorial005.py

    from typing import Dict
    
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/keyword-weights/", response_model=Dict[str, float])
    async def read_keyword_weights():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 205 bytes
    - Viewed (0)
Back to top