为什么此代码返回异常:
raise TypeError(f'Object of type {o.class.name}
TypeError: Object of type set is not JSON serializable
我的代码:
import requests
json_data = {"Челябинская обл, г Челябинск, ул Ворошилова, д 55"}
resp = requests.post('https://dadata.ru/api/v2/suggest/address', json=json_data)
resp.json()
print(resp.json()[0]['region_fias_id'])
正如上面所说,您的
json_data
变量是一个集合根据docs of the API you are using,看起来您需要一个带有“查询”键的dict:
尽管也要注意,您需要在该帖子的标题中包含API密钥:
相关问题 更多 >
编程相关推荐