国产成人AV无码一二三区,少女1到100集,国产精品久久久久精品综合紧,巜公妇之诱感肉欲HD在线播放

文章 > Python基础教程 > python中isinstance函数判断各种类型的小细节

python中isinstance函数判断各种类型的小细节

头像

silencement

2019-07-22 09:40:024038浏览 · 0收藏 · 0评论

1. 基本语法

isinstance(object, classinfo)

Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) 
subclass thereof. Also return true if classinfo is a type object (new-style class) and object is an object of that 
type or of a (direct, indirect or virtual) subclass thereof. If object is not a class instance or an object of the
 given type, the function always returns false. If classinfo is neither a class object nor a type object, it may be a 
 tuple of class or type objects, or may recursively contain other such tuples (other sequence types are not accepted). 
 If classinfo is not a class, type, or tuple of classes, types, and such tuples, a TypeError exception is raised.

classinfo 处可以是 a class, type, or tuple of classes and types,

如果是 tuple,则满足 tuple 中的任何一个即返回 True

2. 字符串的类型判断。

字符串,分为 str 和 unicode,二者均继承自 basestring

>>> isinstance(u'3.0', unicode)
True
>>> isinstance('3.0', str)
True
>>> isinstance(u'3.0', str)
False
>>> isinstance(u'3.0', str)
False
>>> isinstance(u'3.0', basestring)
True
>>> isinstance('3.0', basestring)
True

3. 数字的类型判断

数字分为 int 和 float,暂未发现二者共同的有效父类。

可以用 (int, float) tuple 来判断是否为数字(int 或 float)

>>> isinstance('3', (int, float))
False
>>> isinstance(3.0, (int, float))
True
>>> isinstance(3, (int, float))
True
>>> isinstance(3.0, float)
True
>>> isinstance(3.0, int)
False
>>> isinstance(3, float)
False
>>> isinstance(3, int)
True
关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

免费观看已满十八岁电视剧国外| (NP、高H、纯肉)高H高辣| 办公室狂C小雪秘书好爽H| 《交换做爰》在线观看| 苏州华东装饰城| 黏糊糊的你》动漫免费观看| 姨母的绣感中字2| 《与上司做爰HD》| 妈妈的绣感| 朋友的未婚妻| 香港明星| 欧美大片PPT免费PPT| 温柔女教师在线观看电视剧大全| 玉女献身台湾1988版主演是谁| 一起长大的约定| 日本MV与欧美MV的区别| Y丫影院免费观看电视剧| 电视剧中国地| 成色18K1.8.35MB| 《伦敦空姐美版2023》| 妈妈你真棒插曲快来救救我电影| 免费外国网站浏览器推荐| 梁祝艳谭5免费观看| 母与子免费观看大全电视剧| 11BBB| 欧美大片PPT免费大全| 《酒店激战》动漫1-5集免费观..| 憋尿白丝小肚子凸起高冷知乎 | 美国A片巜禁忌9| 国产少女免费观看电视剧大全 | 妈妈的闺蜜| 双乳被四个男人吃奶 | 禁忌1蜜桃熟了| 《疯狂72小时》韩剧| 少女尖叫之夜1-4集免费| 含着奶做着爱太舒服了| 《喂奶人妻厨房HD》| 兽父1到16集一口气看完| 老牛耕田陈雪435章| 满18岁免费观看高清电视剧大全| 欧美人与人动人物2024心理学