我有三个分类如下:
class one():
def __init__(self):
self.x = 1
self.y = 3
self.h = self.x + self.y
from file1 import *
class two():
def __init__(self,coming):
self.get = coming.h+1
from file1 import *
from file2 import *
class three():
def __init__(self,f1,f2):
self.v1 = f1.h
self.v2 = f2.get
print(self.v1)
print(self.v2)
k = three(two(one()))
每当我运行file3.py时,我都需要这样的结果:
> 4
> 5
但是我的代码给出了file2不返回任何值,然后我的错误:
〜#python file3.py
Traceback (most recent call last):
File "file3.py", line 10, in <module>
k = three(two(one()))
TypeError: __init__() takes exactly 3 arguments (2 given)
答案 0 :(得分:0)
问题是三个得到2个参数而不是3个。 您可以将file3中的最后一行更改为:
R6010 - abort() has been called
或以不同方式设计代码