dogs.dict()序列化,為什么打印沒有weight這個屬性?
dogs?=?Dog(birthday=date.today(),?weight=6.66,?sound=[{'sound':?'w?w~~'},?{'sound':?'y?y~~'}]) print(dogs.dict()) >>?{'birthday':?datetime.date(2021,?12,?1),?'sound':?[{'sound':?'w?w~~'},?{'sound':?'y?y~~'}]}
dogs?=?Dog(birthday=date.today(),?weight=6.66,?sound=[{'sound':?'w?w~~'},?{'sound':?'y?y~~'}]) print(dogs.dict()) >>?{'birthday':?datetime.date(2021,?12,?1),?'sound':?[{'sound':?'w?w~~'},?{'sound':?'y?y~~'}]}
2021-12-01
舉報
2021-12-10
老師的寫法是 weight: float = Optional[None]
我猜是這樣的,具體兩個什么區(qū)別,不知道呢