【发布时间】:2020-02-01 09:12:56
【问题描述】:
class student :
def __init__(self,name,rno) :
self.name=name
self.rno=rno
self.Lap=self.Laptop
def show(self) :
print(self.name,self.rno)
self.Lap.show()
class Laptop:
def __init__(self) :
self.brand="hp"
self.cpu="i5"
self.ram=8
def show(self):
print(self.brand,self.cpu,self.ram)
s1=student("ravi",2)
s2=student("kumar",3)
s1.show()
我收到以下错误:
TypeError: show() 缺少 1 个必需的位置参数:'self'
【问题讨论】:
标签: python