質問するログイン新規登録

回答編集履歴

3

修正

2020/06/28 07:11

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -12,6 +12,7 @@
12
12
  ## 追記
13
13
 
14
14
  追記を見ましたが、辞書を JSON 形式にするのが目的であれば、json.dumps() でよいのではないでしょうか
15
+ この関数は辞書を json 文字列に変換します。
15
16
 
16
17
  ```python
17
18
  import json
@@ -19,4 +20,5 @@
19
20
  text_dic = {0: "Why", 1: "the same", 2: "the storyline", 3: "When the final"}
20
21
 
21
22
  print(json.dumps(text_dic))
23
+ # {"0": "Why", "1": "the same", "2": "the storyline", "3": "When the final"}
22
24
  ```

2

修正

2020/06/28 07:11

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ## 追記
13
13
 
14
- 辞書を JSON 形式にしたい場合は、json.dumps() でよいのでは
14
+ 追記を見ましたが、辞書を JSON 形式にするのが目的であれば、json.dumps() でよいのではないでしょうか
15
15
 
16
16
  ```python
17
17
  import json

1

修正

2020/06/28 07:10

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -7,4 +7,16 @@
7
7
  print(d)
8
8
  # {'0': 'Why', '1': 'the same', '2': 'the storyline', '3': 'When the final'}
9
9
 
10
+ ```
11
+
12
+ ## 追記
13
+
14
+ 辞書を JSON 形式にしたい場合は、json.dumps() でよいのでは?
15
+
16
+ ```python
17
+ import json
18
+
19
+ text_dic = {0: "Why", 1: "the same", 2: "the storyline", 3: "When the final"}
20
+
21
+ print(json.dumps(text_dic))
10
22
  ```