为什么说:'Klasa' object has no attribute 'ispisi?当 ispisi 是我要调用的方法时
Why does it says: 'Klasa' object has no attribute 'ispisi? When ispisi is method that I am trying to call
class Klasa:
def __init__(self,x,y):
self.x = x
self.y = y
def oduzmi(self,x,y):
return x - y
def ispisi(self):
print('rezultat je: ', self.oduzmi(self.x,self.y))
klasa = Klasa(2,3)
klasa.ispisi()
如果您使用 vscode,请检查缩进我建议您检查 Indentation in VS Code
class Klasa:
def __init__(self,x,y):
self.x = x
self.y = y
def oduzmi(self,x,y):
return x - y
def ispisi(self):
print('rezultat je: ', self.oduzmi(self.x,self.y))
klasa = Klasa(2,3)
klasa.ispisi()
class Klasa:
def __init__(self,x,y):
self.x = x
self.y = y
def oduzmi(self,x,y):
return x - y
def ispisi(self):
print('rezultat je: ', self.oduzmi(self.x,self.y))
klasa = Klasa(2,3)
klasa.ispisi()
如果您使用 vscode,请检查缩进我建议您检查 Indentation in VS Code
class Klasa:
def __init__(self,x,y):
self.x = x
self.y = y
def oduzmi(self,x,y):
return x - y
def ispisi(self):
print('rezultat je: ', self.oduzmi(self.x,self.y))
klasa = Klasa(2,3)
klasa.ispisi()