? ? numpy matrix.call this function after newobject = objectLoadFromFile(jsonfile)'''?
? ? ? ? ? ? pass?
?
? ? p = Person('Aidan',22)? ? ? ?
? ? #json.dumps(p)#error will be throwed?
? ? ?
? ? #objectDumps2File(p,'Person.json')?
? ? p.jsonDumps()?
? ? p_l = objectLoadFromFile('p.json')?
? ? ? ?
? ? print 'the decoded obj type: %s, obj:%s' % (type(p_l),repr(p_l))?
Python类有新旧两种,py 2.2 后类定义继承 object 的目的是使这个类成为 new style class, 没有继承 object 的为传统classic class(最终也会继承object)。
类定义中如下两种方法:
class Person():?
class Person(object)?
其区别在于:
若创建新的Person instanc test,则type(test)的输出分别为:
?
?
inspect 模块提供了一系列自省函数,它可以获取模块,类,方法,函数,traceback,帧对象,代码对象的信息。常用的方法getmembers,ismodule,getcallargs,isclass等,更多详细信息参见http://docs.python.org/library/inspect.html。
--------------------------------------分割线 --------------------------------------
--------------------------------------分割线 --------------------------------------