Linked Questions

Popular Questions

Printing dict is not showing expected output

Asked by At

This is the dict data(headers) I am using for REST API get call.

column="name"
order="descending"
headers = {
            'accept': 'application/json',
            'orderby': '{"'+column+'":"'+order[:4]+'"}',
        }
print(headers)

This gives me following output:

{'accept': 'application/json','orderby': '{"\'name\'":"desc"}'}

I am getting 400- BAD Request because of this error in header.

I am expecting the following output that is without '(slash)' in second key-value pair.

How to print this expected output?

{'accept': 'application/json','orderby': '{"name":"desc"}'}

Related Questions