Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
G'day 所有,
在我最后一个问题之后,我一直在自学使用 json 模块并遇到了这个问题。
给定一个不熟悉的数组:
{"Age": 20, "Nickname": "Jim", "Name": "Fred", "Height": 180}
如何在此对象中找到键?
谢谢,
>>> d = {"Age": 20, "Nickname": "Jim", "Name": "Fred", "Height": 180} >>> d.keys() ['Age', 'Nickname', 'Name', 'Height']
或者,更简单地说,如果您打算迭代:
>>> for k in d: ... print k ... Age Nickname Name Height