-
type()函数
a = 1
print(type(a))
s = 'ddd'
print(type(s))
lis = [1,2,3]
print(type(lis))
tu = (1,2,[2,3])
print(type(tu))
输出结果:
<class 'int'>
<class 'str'>
<class 'list'>
<class 'tuple'>
-
isinstance()函数
a = 1
print(isinstance(a,int))
s = 'ddd'
print(isinstance(s,(int,str)))
输出结果:
True
True
网友评论