python.typeerror:

run() missing 1 required positional argument: self

源代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#coding: utf-8

class (object):

def run(self):
print("Animal is running...")

class Dog(Animal):

def run(self):
print("Dog is running...")

def run_twice(animal):
animal.run()
animal.run()

run_twice(Animal())
run_twice(Dog())

class Tortolse(Animal):
def run(self):
print("Tortolse is running slowly...")

run_twice(Tortolse)
bug反馈如图:

"图1"

问题解决:

在查询网上资料,又返回来重写代码后,发现是自己在最后一行的Tortolse后面少了一个圆括号,泪…,加上后就可以运行了.