from urllib.parse import quote
payload = {'key1': 'value  1', 'key2': 'value 2'}
newpayload = {}
for k, v in list(payload.items()):
    newpayload[quote(k)] = quote(v)
print(newpayload)
Use %20 instead of + for space in python query parameters