どのように私はPythonで辞書を横断するのですか?辞書?
Q
辞書?
-1
A
答えて
0
質問を正しく解釈している場合は、さまざまな方法で辞書を横断できます。
初心者の方には、hereとお読みください。
また、辞書はあなたのベスト・ベットではないかもしれません。もっと情報があれば助けになるでしょう。
1
多くの方法!少数だが、それはより複雑なものにこれらの簡単な方法から逸脱し始め
testdict = {"bob" : 0, "joe": 20, "kate" : 73, "sue" : 40}
for items in testdict.items():
print (items)
for key in testdict.keys():
print (key, testdict[key])
for item in testdict.iteritems():
print item
for key in testdict.iterkeys():
print (key, testdict[key])
。すべてのコードがテストされました。
0
http://docs.python.org/tutorial/datastructures.html#looping-techniques
>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
>>> for k, v in knights.iteritems():
... print k, v
...
gallahad the pure
robin the brave
関連する問題
- 1. ユーザー辞書のリソース辞書
- 2. 辞書のpython辞書
- 3. 条件付き辞書のPython辞書
- 4. Tensorflow辞書テンソルでの辞書検索
- 5. 辞書を考える辞書
- 6. OOPの辞書オブ辞書ですか?
- 7. 辞書のリストから辞書
- 8. 辞書<string、string> with child辞書
- 9. 辞書
- 10. 辞書
- 11. 辞書
- 12. 辞書
- 13. 辞書
- 14. 辞書
- 15. 辞書
- 16. Python辞書/リストヘルプ
- 17. Pythonの辞書
- 18. 辞書検索
- 19. 辞書キャスト
- 20. 辞書。 java.lang.ArrayStoreException
- 21. 別の辞書
- 22. C#辞書LINQ
- 23. ソートリスト辞書
- 24. オープンソース辞書ライブラリ
- 25. 辞書リテラルは
- 26. フラスコリセットグローバル辞書
- 27. ActionScript辞書C#
- 28. リストの辞書
- 29. 辞書リスト
- 30. 辞書は
あなたはすでにこれを聞いていませんでした?:http://stackoverflow.com/questions/1006575/how-do-i-traverse-a-dictionary-in-python-closed – gnovice
また、この質問を複製します:http://stackoverflow.com/questions/380734/how-to-do-this-python-dictionary-traverse-and-search – mezoid