1.
*attr()
class myClass(object):
def __init__(self):
self.foo = 100
myInst = myClass()
print hasattr(myInst, 'foo')
print getattr(myInst, 'foo')
print hasattr(myInst, 'bar')
#print getattr(myInst, 'bar')
print getattr(myInst, 'bar', 'oooops')
setattr(myInst, 'bar', 'my attr')
print getattr(myInst,'bar')
print dir(myInst)
print getattr(myInst,'bar')
delattr(myInst, 'foo')
print dir(myInst)
2.
字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作[……]