Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.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 TypeError:\uuuu init\uuuuuu()接受4个位置参数,但给出了5个_Python - Fatal编程技术网

Python TypeError:\uuuu init\uuuuuu()接受4个位置参数,但给出了5个

Python TypeError:\uuuu init\uuuuuu()接受4个位置参数,但给出了5个,python,Python,我查过类似的问题,但大多数问题都与在\uuuu init\uuu定义中省略self参数有关 代码: 然而,在我将“optionsdic”添加到类之前,我的代码运行良好。添加后,我在标题中得到类型错误。我是否将**kwargs错误地用作参数 您需要使用**将选项DIC应用为关键字参数: testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", **optionsdic) testurl = steamurl("IDOTA2M

我查过类似的问题,但大多数问题都与在
\uuuu init\uuu
定义中省略
self
参数有关

代码:


然而,在我将“optionsdic”添加到类之前,我的代码运行良好。添加后,我在标题中得到类型错误。我是否将
**kwargs
错误地用作参数

您需要使用
**
选项DIC
应用为关键字参数:

testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", **optionsdic)
testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", **optionsdic)
否则,它只是另一个传入dictionary对象的位置参数


这反映了函数签名中的语法。

您应该使用
**
调用:

testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", optionsdic)

这将把字典解压成单独的关键字参数。在
\uuuu init\uuuuu
中,由于
**options
的原因,关键字参数将被打包到字典中。如果要将
optionsdic
的内容作为单独的关键字参数传递,则需要使用
**

testurl = steamurl("IDOTA2Match_570", "GetMatchHistory", "v001", **optionsdic)