python - String/dict manipulation ' to " -
{'coolstring': {'stepone': {'x': '44', 'y': '66'}}}
this string/dictionary create input(), however, need change ' or apostrophes " or quotation marks. reasoning need passed json string further down pipeline.
my idea using .replace() i'm not quite sure how format swaps ' " tips?
if input dictionary, there's json
module need:
import json dic = {'coolstring': {'stepone': {'x': '44', 'y': '66'}}} json_string = json.dumps(dic) print(json_string)
the output be:
{"coolstring": {"stepone": {"x": "44", "y": "66"}}}
however if data string, can use proposed solution other comment using replace()
Comments
Post a Comment