python 类和实例

[root@centos6 tmp]# cat a1.py 
class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    
    def say_hello(self,str):
        print(str)

    def change_name(person, new_name):
       person.name = new_name
print(type(Person))
p = Person("Alice", 25)
print(type(p))
print(dir(p))
print(p.say_hello('11111111'))


[root@centos6 tmp]# python a1.py 


['__doc__', '__init__', '__module__', 'age', 'change_name', 'name', 'say_hello']
11111111
None

你可能感兴趣的:(python,高级编程,python,开发语言)