Reference: http://planet.python.org/
python2中 print 'hello world'
python3中 print ('hello world')
获取属性的方法使用__dict__
import inspect
class Test:
""""""
#--------------------------------------------
def __init__(self):
self.varOne = ""
self.varTwo = ""
self.varThree = ""
#--------------------------------------------
def methodOne(self):
""""""
# print "You just called methodOne!"
print ("You just called methodOne!")
#----------------------------------------------------
if __name__ == "__main__":
t = Test()
variables = [i for i in t.__dict__ if not inspect.ismethod(i)]
print (variables)
print ('End of File')
以下两种方法也可以,并且第二种不需要import inspect.
variables = [i for i in t.__dict__ if not callable(i)]
variables = t.__dict__.keys()