typechk.py代码:
#!/usr/bin/env python
#
def displayNumType(num):
if isinstance(num, (int,long,float,complex)):
#isinstance接受一个参数num,判断是什么类型。
print ‘a number of tpye:’,type(num).__name__
else:
print ‘not a number at all!!’
displayNumType(-69)
displayNumType(999999999999999)
displayNumType(76.4)
displayNumType(-5.3+1.9j)
displayNumType(‘xxx’)