Python 3.x 实例变量和数据属性
在这段代码中,c.x实例是变量吗?self.x是数据属性,对吗Python 3.x 实例变量和数据属性,python-3.x,oop,instance,Python 3.x,Oop,Instance,在这段代码中,c.x实例是变量吗?self.x是数据属性,对吗 class Coordinate (object): def __init__ (self, x, y): self.x = x self.y = y c = Coordinate (3,4) print (c.x) 在上述代码中: self.x和self.y是类的属性 c、 x和c.y是实例变量。对于不同的实例,所有实例变量都有不同的值 实际参数是在调用函数时指定的参数。形式参数是定
class Coordinate (object):
def __init__ (self, x, y):
self.x = x
self.y = y
c = Coordinate (3,4)
print (c.x)
在上述代码中:
是的,你是正确的。那么实际参数(3,4)是什么?是的,你是正确的。那么实际参数(3,4)是什么?
class Coordinate (object):
def __init__ (self, x, y):
self.x = x
self.y = y
c = Coordinate (3,4)
print (c.x)