简体   繁体   中英

Python requests, how to send json request without “ ”

my code looks like

            data = {
                "undelete_user":'false'
            }
            data_json = json.dumps(data)
            print(data_json)

Output is:

{"undelete_user": "false"}

i need output to be without "" so it can look like

{"undelete_user": false}

otherwise when i send request, i will get "failed to decode JSON" error

import json


data = {
    "undelete_user": False
}
data_json = json.dumps(data)
print(data_json)

All you had to do was remove 'false' and put False, because you're considering your false as a string, and it should be a boolean. I hope it helped!

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