type()

pi@raspberrypi ~ $ python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> type('')
<type 'str'>
>>> s = 'xyz'
>>> type(s)
<type 'str'>
>>> type(100)
<type 'int'>
>>> type(0+0j)
<type 'complex'>
>>> type(0)
<type 'int'>
>>> type(0)
>>> type(0)
>>> type(0)
>>> type(0L)
<type 'long'>
>>> type(0.0)
<type 'float'>
>>> type([])
<type 'list'>
>>> type(())
<type 'tuple'>
>>> type({})
<type 'dict'>
>>> type(type)
<type 'type'>
>>> type(type)
<type 'type'>
>>> class Foo:pass
... 
>>> type(Foo)
<type 'classobj'>
>>> foo = Foo()
>>> 
>>> type(foo)
<type 'instance'>
>>> class Bar(object): pass
... 
>>> bar = Bar()
>>> type(Bar)
<type 'type'>
>>> type(Bar)
<type 'type'>
>>> bar = Bar()
>>> type(Bar)
<type 'type'>
>>> type(bar)
<class '__main__.Bar'>
>>> 
原文地址:https://www.cnblogs.com/flintlovesam/p/5357428.html