python面向对象学习系列-1 hello 面向对象

# encoding: utf-8
import arcpy
class person():
    def __init__(self,name,age):
        self.name=name
        self.age=age
    def getAge(self):
        print self.age
p1=person("lyp",23)
p1.getAge()

其中__init__方法会在实例化时自动调用。类似于静态语言中的构造函数吧.

其他常见规范见 PEP8规范

猜你喜欢

转载自blog.csdn.net/A873054267/article/details/87903463