您的位置:首页 > 其它

type()

2016-04-05 23:25 363 查看
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'>
>>>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: