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
这是因为您是在jsondeconder类上调用方法,而不是在它的实例上。这将起作用:
相关问题 更多 >
编程相关推荐