调用对象'Ball'时报错TypeError 有谁知道是怎么回事
class Ball:def setName(self,name):
self.name = name
def kick(self):
print('我叫%s噢,谁踢的我?' % self.name)
a = Ball
a.setName('土豆')
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
a.setName('土豆')
TypeError: setName() missing 1 required positional argument: 'name'
#这代码有什么问题吗?总是报错TypeError 少个括号
class Ball:
def setName(self,name):
self.name = name
def kick(self):
print('我叫%s噢,谁踢的我?' % self.name)
a = Ball()
a.setName('土豆')
页:
[1]