問題一:list [object] 轉成json
class Employee:
aaa = ""
bbb = ""
ccc = ""
ddd = ""
=======================
import test
import json
abc = []
aaa = test.Employee()
bbb = test.Employee()
aaa.aaa = "a1"
aaa.bbb = "b1"
aaa.ccc = 14
bbb.aaa = "a11"
bbb.ccc = "c11"
bbb.ddd = 36
abc.append(aaa)
abc.append(bbb)
print(json.dumps(abc))
TypeError: Object of type Employee is not JSON serializable
==================================================
問題二,有沒有辦法把dict 轉成list+object
{"a1":1,"a2":2}{"b1":1,"b2":2} 轉成 list + object
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/273409.html
上一篇:python飛機大戰
