python内建函数type()
来源:互联网 发布:爱奇艺会员淘宝关键字 编辑:程序博客网 时间:2024/06/05 11:48
print type('')s='xyd'print type(s)print type(199)print type(0+0j)print type(1+8j)print type('long')print type(0.0)print type([])print type(())print type(type)class Foo:passfoo = Foo()print type(Foo)print type(foo)class Bar(object):passbar = Bar()print type(bar)print type(Bar)
<type 'str'><type 'str'><type 'int'><type 'complex'><type 'complex'><type 'str'><type 'float'><type 'list'><type 'tuple'><type 'type'><type 'classobj'><type 'instance'><class '__main__.Bar'><type 'type'>
#------------------------isinstance()-----------------------------------------#def displayNumType(num): print num,'is', if isinstance(num,(int,long,float,complex)): #isinstance()函数里面接受一个类对象作为参数 print 'a number of type:',type(num) else: print 'not a number at all'displayNumType(90.0)displayNumType(2+9j)displayNumType(23)
输出
90.0 is a number of type: <type 'float'>(2+9j) is a number of type: <type 'complex'>23 is a number of type: <type 'int'>
阅读全文
0 0
- python内建函数type()
- Python基础-3内建函数 type() cmp()
- python 内建函数isinstance的用法以及与type的区别
- python 内建函数isinstance的用法以及与type的区别
- Python 内建函数
- Python内建函数
- Python内建函数
- Python 内建函数
- python 内建函数
- python内建函数
- Python内建函数
- Python 内建函数
- Python--内建函数
- python-内建函数
- python 内建函数
- Python--内建函数
- python内建函数
- python内建函数
- AOP切点的合并
- 问题 O: 选美比赛
- 数据结构——队列
- 用Java代码读取Ecxel文件,再存入mysql数据库
- 【软工学习】第十二章——数据流图技术
- python内建函数type()
- 第一篇博客
- 问题 P: 字符串数字置换
- C++面试题
- LintCode-[容易] 491. 回文数
- HYSBZ 2818 莫比乌斯函数(不能化1的情况)
- 数据结构——栈
- 问题 Q: 写出来吧
- vsprintf,vsprintf_s