python __class__ type理解
2016-03-08 15:54
471 查看
>>> if a.__class__ == A:
... print '=='
...
==
>>> if a.__class__ == type(a):
... print '--';
...
--
>>> if a.__class__ == A.__class__:
... print "=="
...
>>> print A.__class__
<type 'type'>
>>> print a.__class__
<class '__main__.A'>
对于对象实例:type(instance) == instance.__class__ 等于A
A.__class__则返回的是 其中的类型 对象类 type 所有的 类的B.__class__返回都是一样的
... print '=='
...
==
>>> if a.__class__ == type(a):
... print '--';
...
--
>>> if a.__class__ == A.__class__:
... print "=="
...
>>> print A.__class__
<type 'type'>
>>> print a.__class__
<class '__main__.A'>
对于对象实例:type(instance) == instance.__class__ 等于A
A.__class__则返回的是 其中的类型 对象类 type 所有的 类的B.__class__返回都是一样的
相关文章推荐
- python __file__ 与argv[0]
- python (7)读取整个目录的所有文件夹并存入
- 机器学习系列(3)_逻辑回归应用之Kaggle泰坦尼克之灾
- Python正则表达式指南
- Python 主要模块介绍
- Ubuntu-Python2.7安装 scipy,numpy,matplotlib (转)
- python学习 1基础
- 在Xcode7中搭建Python开发环境
- python 遗传算法精简版
- LeetCode----Lowest Common Ancestor of a Binary Tree
- python模拟登录带cookie
- Python 资源
- 【python】编程语言入门经典100例--26
- Python——管理属性(2)
- python项目之 爬虫爬取煎蛋jandan的妹子图-上
- Python 知识结构图
- LeetCode----Lowest Common Ancestor of a Binary Search Tree
- Python爬取中文页面的时候出现的乱码问题
- 使用python的PIL库简单的处理图像
- 简体中文转繁体的python简单实现