Python:按类排序的结果排名?

时间:2016-04-08 10:10:05

标签: python python-2.7 class python-3.x

我有三个分类如下:

file1.py

class one():
    def __init__(self):
        self.x = 1
        self.y = 3
        self.h = self.x + self.y

file2.py

from file1 import *
class two():
    def __init__(self,coming):
        self.get = coming.h+1

file3.py

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)

1 个答案:

答案 0 :(得分:0)

问题是三个得到2个参数而不是3个。 您可以将file3中的最后一行更改为:

R6010 - abort() has been called

或以不同方式设计代码