我不熟悉Google Apps API,但看来
orgunits.list()定义为:
class FactoryObject(object):
# ... Code Here ...
def list(self, **kwargs):
if 'some_parameter' not in kwargs:
raise Exception('some_parameter required argument')
# ... code that uses kwargs['some_parameter']
return True
因此,如果我运行以下命令:
>>> orgunits.list()
Exception: some_parameter required argument
>>> orgunits.list('my_customer')
TypeError: list() takes exactly 1 argument (2 given)
>>> orgunits.list(some_parameter='my_customer')
True
因此,下次您看到错误时,请尝试将参数名称添加到您的参数列表中,然后查看是否解决问题。
更多信息:
字典拆箱操作员(**)的作用不像参数列表中的普通参数。如果您通过位置参数,那么当这是列表中唯一的参数时,它将引发错误(如您所见),因为代码正在期待关键字参数。
解开操作员可以接受任意关键字参数,并在字典中使用它们。