发布时间:2019-06-21 17:36:01编辑:auto阅读(2309)
import types
aaa = 0
print type(aaa)
if type(aaa) is types.IntType:
print "the type of aaa is int"
if isinstance(aaa,int):
print "the type of aaa is int"
bbb = 'hello'
print type(bbb)
if type(bbb) is types.StringType:
print "the type of bbb is string"
if isinstance(bbb,str):
print "the type of bbb is string"
#if the type is NoneType,the isinstance does not work
#we should judge the NoneType like below
#if row is None
#if type(row) is types.NoneType
#In my opinion,use the types to judge the type of a param is convinient<SPANstyle="BACKGROUND-COLOR: rgb(255,255,255); FONT-FAMILY: Arial">, use the isinstance to judge whether a instance is a type of a class or not</SPAN>
上一篇: python 实现终端中的进度条
下一篇: python模块paramiko与ssh
49410
48612
39301
36386
30791
27607
26596
21418
21282
19630
281°
533°
502°
603°
1014°
681°
1366°
1604°
1267°
1248°