【问题标题】:SyntaxError: non-keyword arg after keyword arg in arguments functionSyntaxError:参数函数中关键字 arg 之后的非关键字 arg
【发布时间】:2013-08-25 15:36:51
【问题描述】:

我有这个功能:

def crypting(self, client, access_token, client_id, client_secret, oauth_scope, redirect_uri):

标题中的错误在这个函数中:

FCU.crypting(client = None, access_token = None, client_id, client_secret, oauth_scope, redirect_uri)

为什么? 感谢您的解决方案。

【问题讨论】:

    标签: python function arguments args


    【解决方案1】:

    这就是它所说的。您不能在关键字参数之后传递非关键字参数。如果你有类似client=None 的东西,那是一个关键字参数,所有这些都必须出现在参数列表的 end 中。

    【讨论】:

      【解决方案2】:

      用其他方法解决的问题:

      variable1 = None
      variable2 = None
      
      class.function(variable1, variable2, client_id, client_secret)
      

      【讨论】:

        【解决方案3】:

        在此处查看第 4.7.2 节:

        http://docs.python.org/2/tutorial/controlflow.html

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-09-17
          • 2020-08-15
          • 1970-01-01
          相关资源
          最近更新 更多