Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Python:can';“t通行证”;“自我”;作为唯一的论据_Python 3.x_Graph - Fatal编程技术网

Python 3.x Python:can';“t通行证”;“自我”;作为唯一的论据

Python 3.x Python:can';“t通行证”;“自我”;作为唯一的论据,python-3.x,graph,Python 3.x,Graph,我正在写一个代码来简化一个图表。在本例中,我需要删除一个2度节点,并将其两个相邻节点相互连接。这是简化的代码 class node(): def __init__(self,ind): #some code self.neighbors=queue() #queue is another class defined by me self.distances=queue() #some code

我正在写一个代码来简化一个图表。在本例中,我需要删除一个2度节点,并将其两个相邻节点相互连接。这是简化的代码

class node():
    
    def __init__(self,ind):
        #some code

        self.neighbors=queue()  #queue is another class defined by me
        self.distances=queue()

        #some code
        
        
    def addngh(self,nd,distance):
        #some code
            
    def remngh(self,nd):           #remove node "nd" from neighbors queue
        #some code
        
    def d2noderem(self):           #removing self node from its left,right neighbors' "neighbors" queue by passing self to left and right's "remngh" function
        
        left,right = self.neighbors[0:2]

        #some code
        
        left.remngh(self)  #======= Error occurs at here ==========
        right.remngh(self)
        
        #some code
当我调用d2noderem函数时,会发生以下错误

文件“/path/to/File/simplegraphs.py”,第51行,在d2noderem中
左。remngh(自我)

TypeError:remngh()缺少1个必需的位置参数:“nd”

然后我试了一下

left.remngh(self,self)
这就是结果

文件“/path/to/File/simplegraphs.py”,第51行,在d2noderem中
左。remngh(self,self)

TypeError:remngh()接受2个位置参数,但给出了3个

我不明白参数的数量是如何通过增加1个参数从0增加到3的

我还没有找到解决这个问题的办法

如何克服这类问题


非常感谢您的帮助

方法“remng”需要一个参数,该参数由
def remngh(self,nd)中的参数“nd”定义:
因为您调用它时没有提供所需的参数,所以它抛出了一个错误

您应该提供预期的参数,或者完全重写函数