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

python 判断自定义对象类型

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 11:26:59
Original
2150 people have browsed it

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

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

Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template