我有一个函数,通过API更新记录。该API接受多种可选的关键字参数:
def update_by_email(self, email=None, **kwargs):
result = post(path='/do/update/email/{email}'.format(email=email), params=kwargs)
我有另一个函数,它使用第一个函数来更新记录中的特定字段:
def update_field(email=None, field=None, field_value=None):
"""Encoded parameter should be formatted as <field>=<field_value>"""
request = update_by_email(email=email, field=field_value)
这不起作用。当我调用:
update_field(email='joe@me.com', field='name', field_value='joe')
URL被编码为:
https://www.example.com/api/do/update/email/joe@me.com?field=Joe
如何使它编码为:
https://www.example.com/api/do/update/email/joe@me.com?name=Joe
提前感谢。