TypeError:必须以jsondeconder实例作为第一个参数调用unbound方法decode()(改为获取PrintJson实例)

2024-06-01 01:47:11 发布

您现在位置:Python中文网/ 问答频道 /正文

TypeError: unbound method decode() must be called with JSONDecoder instance as first argument (got PrintJson instance instead)

当我试图将python对象解析为json时,我遇到了这个错误。在

使用以下代码:

import json
from json import JSONDecoder

class TestJson():
    name = None
    pass

printJson = PrintJson()
print printJson
print JSONDecoder.decode(printJson) // at this line, getting this error

Tags: instanceimportjsonbethismethodprintdecode