第三发

type()

type(int) type(3)

type(123)==type(456)

import types

type("abc") == types.StringType

所有类型本身的类型就是TypeType,例:

type(int)==types.TypeType

isinstance("a",(str,unicode))

dir("a")返回一个包含字符串的list

len("a")等价于"a".__len__()

hasattr(obj,"x")#有x属性么?

getattr(obj,"x")#获取x属性,如果没有,会抛异常

getattr(obj,"x",19)#如果没有x属性值,就返回19这个默认值

setattr(obj,"y",19)#等价于obj.y = 19

has

原文地址:https://www.cnblogs.com/say-one-say/p/4933883.html