import types
aaa = 0
print type(aaa)
iftype(aaa) is types.IntType:
print "the type of aaa is int"if isinstance(aaa,int):
print "the type of aaa is int"
bbb = 'hello'
print type(bbb)
iftype(bbb) is types.StringType:
print "the type of bbb is string"if isinstance(bbb,str):
print "the type of bbb is string"
#if the typeis NoneType,the isinstance does not work
#we should judge the NoneType like below
#if row is None
#iftype(row) is types.NoneType
#In my opinion,use the types to judge the typeof a param is convinient, use the isinstance to judge whether a instance is a typeof a class ornot