dir()函数,它返回一个包含字符串的list,比如,获得一个str对象的所有属性和方法:print(dir('obj'))
配合getattr()、setattr()以及hasattr(),我们可以直接操作一个对象的状态。