'How to force a dictionary to be written with " " instead of ' ' [duplicate]
So I am working on a project in which I build an ongoing dictionary for kennings (its for a norse mythology course). The problem I run into is on occasion a kenning has an apostrophe in it. For example the kenning "wolf's joint" which has the definition "joint" gets written to the dictionary as {"wolf's wrist": 'joint'}, this would be fine if the json.loads() function didn't through up an error because the key has "" and the value has ''. I was wondering if there is a way to force a dict to be written always with the "" instead of ''.
Solution 1:[1]
You can try json.dumps:
>>> print(json.dumps({"wolf's wrist": 'joint'}))
{"wolf's wrist": "joint"}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Antony Hatchkins |
