首页 > 编程语言 > 详细

Python之对象的属性

时间:2015-11-06 23:33:28      阅读:262      评论:0      收藏:0      [点我收藏+]
# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#Python之对象的属性
#http://python.jobbole.com/82622/


#对象的属性

class bird():
    feather = True
 
class chicken(bird):
    fly = False
    def __init__(self,age):
        self.age = age


summer = chicken(2)
print(bird.__dict__)
print(chicken.__dict__)
print(summer.__dict__)
‘‘‘
{‘__module__‘: ‘__main__‘, ‘feather‘: True, ‘__doc__‘: None}
{‘fly‘: False, ‘__module__‘: ‘__main__‘, ‘__doc__‘: None, ‘__init__‘: <function __init__ at 0x02042AB0>}
{‘age‘: 2}
‘‘‘

 

Python之对象的属性

原文:http://www.cnblogs.com/dengyg200891/p/4943913.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!