简体   繁体   中英

Python is converting double quotes to single quotes in new variable

I'm trying to save a variable with double quotes in python, because I need to pass the double quoted JSON to a template and single quotes wont work with what I'm doing. So I set the variable in python to:

json = {
  "auth": {
    "key": "auth-code-here"
  },
  "template_id": "id-here",
  "redirect_url": "url-here",
}

But immediate in python, it's saved as

{'redirect_url': 'url-here', 'template_id': 'id-here', 'auth': {'key': 'auth-code-here'}}

Is there a way I can save it as double quoted? Or will I need to process this in a django template to replace the single quotes for double quotes?

Thanks!

You should use a JSON module to do that. To Python, double- and single-quotes are interchangeable.

Python has JSON abilities built in .

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