code: def serialize_instance(obj):
      
      obj_dict = {'__classname__': type(obj).__name__}
      obj_dict.update(obj.__dict__)
      for key, value in obj_dict.items():
          if not isinstance(value, commonDataType):
              sub_dict = serialize_instance(value)
              obj_dict.update({key: sub_dict})
          else:
              continue
      return obj_dict
docs: 对象序列化
  
      :param:
          * obj: (object) 对象实例
  
      :return:
          * obj_dict: (dict) 对象序列化字典
  
      举例如下::
  
          print('--- serialize_instance demo ---')
          # 定义两个对象
          class Obj(object):
              def __init__(self, a, b):
                  self.a = a
                  self.b = b
  
          class ObjB(object):
              def __init__(self, x, y):
                  self.x = x
                  self.y = y
  
          # 对象序列化
          b = ObjB('string', [item for item in range(10)])
          obj_ = Obj(1, b)
          print(serialize_instance(obj_))
          print('---')
  
      执行结果::
  
          --- serialize_instance demo ---
          {'__classname__': 'Obj', 'a': 1,
          'b': {'__classname__': 'ObjB', 'x': 'string', 'y': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}}
          ---