Python之判断变量类型isinstance函数

<center> Python之判断变量类型isinstance函数 </center>

​ Python的 isinstance函数可以判断指定的变量类型 是否对应,返回值是bool类型

函数原型:

isinstance(object, classinfo)

​ 即 isinstance(变量名,类型)

MyList=[100,20,"hello world"]
MyDict={"name":"Dae"}
MySet={100,20,50}
MyString="hello Python!"
MyInt=50
Myfloat=9.8
print(isinstance(MyList,list))# True
print(isinstance(MyInt,list))#False
print(isinstance(MyString,str))#True
全部评论

相关推荐

想踩缝纫机的小师弟练...:不理解你们这些人,要放记录就把对方公司名字放出来啊。不然怎么网暴他们
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务