简体   繁体   中英

python requests @ params

I try to using request.get with '@' in params, but in output I have '%40' How I can decode this dict?

Using Python3

import requests

payload = {'OPERATION-NAME': 'findItemsByProduct','productId.@type':'ReferenceID'}

req = requests.post(url, params=payload)

print(req.url)

The output is - 'url?productId.%40type=ReferenceID'

Use "data" argument instead of params. You should also specify the header, in this case json and then convert the payload dict to json using json.dumps().

import requests
import json


payload = {'productId.@type':'ReferenceID'}

req = requests.post(url, headers={'Content-Type': 'application/JSON'}, data=json.dumps(payload))

print(req.url)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM