Home  >  Article  >  Backend Development  >  python 判断自定义对象类型

python 判断自定义对象类型

WBOY
WBOYOriginal
2016-06-06 11:26:592077browse

要判断自定义对象的类型,用__class__方法,或者用isinstance(object, class-or-type-or-tuple)-->bool

用__class__不能认出子类实例也是父类的实例,用isinstance可以认出子类实例也是父类的实例

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn