关于 实例化后变量没有输出
class Sound(BaseModel):
sound: str
class Dog(BaseModel):
birthday: date
weight: float = Optional[None]
sound: List[Sound] # 不同的狗有不同的叫声。递归模型(Recursive Models)就是指一个嵌套一个
dogs = Dog(birthday=date.today(), weight=6.66, sound=[{"sound": "wang wang ~"}, {"sound": "ying ying ~"}] )
print(dogs.dict()) # {'birthday': datetime.date(2023, 8, 29), 'sound': [{'sound': 'wang wang ~'}, {'sound': 'ying ying ~'}]}你好,问下,为什么 我实例化的时候定义了 weight=6.66 ,但是结果却没有 输出来呢 。