码迷,mamicode.com
首页 > 其他好文 > 详细

isinstance使用方法

时间:2016-04-28 00:23:40      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

#!/usr/bin/python2.7
    def displayNumType(num):
    print num, ‘is‘,
    if isinstance(num,(int, long, float, complex)):
            print ‘a num of type:‘, type(num).__name__
    else:
            print ‘not a  num at all‘
displayNumType(-69)
displayNumType(99999999)
displayNumType(98.8)
displayNumType(-5.3+9.9j)
displayNumType(‘xxx‘)

isinstance使用方法

标签:

原文地址:http://www.cnblogs.com/flintlovesam/p/5440958.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!