8.1 类的一般形式

时间:2017-11-10 12:36:09   收藏:0   阅读:244
class ren(object):
    ‘‘‘this class is about ren class。类的说明,使用三个单引号‘‘‘
    name=‘菇凉‘
    sex=‘Female‘
    def hello(self):
        print(‘hello world‘)
a=ren()
print(type(a))
print(a.name)
print(a.sex)
a.hello()
a.name=‘未来啊‘
print(a.name)

返回结果:

<class ‘__main__.ren‘>

菇凉

Female

hello world

未来啊


原文:http://shaoniana.blog.51cto.com/11471609/1980560

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!