回答編集履歴

1

d

2019/03/02 13:34

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -13,8 +13,6 @@
13
13
  import re
14
14
 
15
15
  from collections import OrderedDict
16
-
17
- from io import StringIO
18
16
 
19
17
 
20
18
 
@@ -38,11 +36,13 @@
38
36
 
39
37
 
40
38
 
41
- io = StringIO()
39
+ j = json.dumps(data, indent=2, ensure_ascii=False)
42
40
 
43
- json.dump(data, io, indent=2, ensure_ascii=False)
41
+ # 正規表現でキーの引用符を消す。
44
42
 
45
- j = re.sub(r'"(\w+?)":', r'\1:', io.getvalue())
43
+ j = re.sub(r'"(\w+?)":', r'\1:', j)
44
+
45
+
46
46
 
47
47
  with open('data.json', 'w') as f:
48
48