【发布时间】:2021-01-06 06:55:54
【问题描述】:
我们可以声明一个继承 basemodel 的模型并在其中放入一个值,而不是普通的 Python 模型吗?
我可以强制创建 PyTimeZoneSetting 模型,但我可以使用现有的 TimeZoneSetting 吗?
from pydantic import BaseModel
from typing import List, Optional
class TimeZoneSetting(BaseModel):
time_zone: str
type: int
sync_time: Optional[str] = None
time_server: Optional[str] = None
time_set_type: Optional[int] = None
class PyTimeZoneSetting():
time_zone: str
type: int
sync_time: str
time_server: str
time_set_type: str
def update_system_timezone():
!Here, I want to create a TimeZoneSetting model and put in a value.!
【问题讨论】:
标签: python-3.x fastapi pydantic