# -*- coding: utf-8 -*- #sharejs.com提供代码,转载请注明出处 class Site(object): def __init__(self): self.title = 'share js code' self.url = 'http://www.sharejs.com' def list_all_member(self): for name,value in vars(self).items(): ###dir()和vars()的区别就是dir()只打印属性(属性,属性......)而vars()则打印属性与属性的值(属性:属性值......) print('%s=%s'%(name,value)) if __name__== '__main__': site = Site() site.list_all_member() url=http://www.sharejs.com title=share js code