dictionary = {}
dictionary['a'] = 1
dictionary['b'] = 2
dictionary['c'] = 3
dictionary['d'] = 4
dictionary['e'] = 5
print(dictionary)
実行このコード1回目:
{'c': 3, 'd': 4, 'e': 5, 'a': 1, 'b': 2}
第二:
{'e': 5, 'a': 1, 'b': 2, 'd': 4, 'c': 3}
第三:
{'d': 4, 'a': 1, 'b': 2, 'e': 5, 'c': 3}
私のexp ected結果:
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
または私のコードがある場合:
dictionary = {}
dictionary['r'] = 150
dictionary['j'] = 240
dictionary['k'] = 98
dictionary['l'] = 42
dictionary['m'] = 57
print(dictionary)
#The result should be
{'r': 150, 'j': 240, 'k': 98, 'l': 42, 'm': 57}
ため、私のプロジェクトの100の++リストと辞書は、ファイルに書き込みますし、それが簡単に読むことをします。
P.S.私の英語のために申し訳ありません、私の質問のタイトルが明確でない場合。
ありがとうございます。
しかし、もしそれを最後にファイルに出力したいのであれば、それはあまり有用ではないと思いませんか?** JSON **構造をプリントアウトするコンビネーション辞書ではありません。 – harshil9968
@ harshil9968:その場合は、 'json.dumps()'を使います。更新された答え –