旧课后作业36
class Person:name = '小甲鱼'
def printName(self):
print(self.name)
a = Person
a.printName()
为什么报错TypeError: printName() missing 1 required positional argument: 'self' class Person:
name = '小甲鱼'
def printName(self):
print(self.name)
a = Person()
a.printName()
调用时错了,少了个括号,粗心了吧~~
欢迎追问 居然是引用时候少了个括号,淦 调用类的时候记得加括号 class Person:
name = '小甲鱼'
def printName(self):
print(self.name)
a = Person()
a.printName()
页:
[1]