回答編集履歴
1
追記
answer
CHANGED
@@ -7,4 +7,13 @@
|
|
7
7
|
>>>
|
8
8
|
>>> print(s.replace('"', r'\"'))
|
9
9
|
\"クォーテーションを置換\"
|
10
|
+
```
|
11
|
+
|
12
|
+
そもそも自前でエスケープする必要があるかどうかは疑問ですが。
|
13
|
+
```Python
|
14
|
+
>>> import json
|
15
|
+
>>>
|
16
|
+
>>> s = '"クォーテーションを置換"'
|
17
|
+
>>> print(json.dumps(s, ensure_ascii=False))
|
18
|
+
"\"クォーテーションを置換\""
|
10
19
|
```
|