最佳答案
如何使Python类可序列化?
class FileItem:def __init__(self, fname):self.fname = fname
尝试序列化为JSON:
>>> import json>>> x = FileItem('/foo/bar')>>> json.dumps(x)TypeError: Object of type 'FileItem' is not JSON serializable