1. 程式人生 > >8.1 類的一般形式

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.1 類的一般形式