python如何打印变量的类型

对于基本类型使用type函数,即

print type(a)

 对于对象,使用__class__,或者直接str()

print a.__class__
print str(a)

 

参考:http://outofmemory.cn/code-snippet/13637/python-get-type-of-variable-or-instance

你可能感兴趣的:(python如何打印变量的类型)