对于基本类型使用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如何打印变量的类型
原文:http://luchuan.iteye.com/blog/2246637