gpt4 book ai didi

python - 如何将 Python dict 序列化为 JSON

转载 作者:太空宇宙 更新时间:2023-11-03 13:37:52 25 4
gpt4 key购买 nike

<分区>

所以我有一些我想序列化为 JSON 的 python 字典

{'someproperty': 0, 'anotherproperty': 'value', 'propertyobject': SomeObject(someproperty=0, anotherproperty=0)}

但是 json.dumps 抛出一个 TypeError: SomeObject(someproperty=0, anotherproperty=0) is not JSON serializable

那么我怎样才能正确地序列化我的 python 字典呢?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com