Python Named Argument is Keyword?

前端 未结 2 1104
眼角桃花
眼角桃花 2020-12-07 02:47

So an optional parameter expected in the web POST request of an API I\'m using is actually a reserved word in python too. So how do I name the param in my method call:

相关标签:
2条回答
  • 2020-12-07 03:12
    args = {'x':1, 'y':1, 'z':1, 'from':1}
    example.webrequest(**args)
    

    // dont use that library

    0 讨论(0)
  • 2020-12-07 03:17

    Pass it as a dict.

    func(**{'as': 'foo', 'from': 'bar'})
    
    0 讨论(0)
提交回复
热议问题