天天看点

8.1 类的一般形式

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

未来啊

上一篇: 8.4 类的重写
下一篇: 7.3 高阶函数

继续阅读