[{'start_date': None, 'end_date': None, 'url': '/projects/development16/iteration/76564', 'locked': False, 'default_iteration': True, 'name': 'Backlog', 'hidden': False, 'iteration_type': 0, 'detail': '', 'story_count': 211, 'include_in_velocity': True, 'id': 76564}, {'start_date': None, 'end_date': None, 'url': '/projects/development16/iteration/76565', 'locked': False, 'default_iteration': False, 'name': 'Archive', 'hidden': False, 'iteration_type': 2, 'detail': '', 'story_count': 2, 'include_in_velocity': True, 'id': 76565}, {'start_date': '2016-02-01', 'end_date': '2016-02-13', 'url': '/projects/development16/iteration/76693', 'locked': False, 'default_iteration': False, 'name': 'Godzilla', 'hidden': False, 'iteration_type': 1, 'detail': '', 'story_count': 27, 'include_in_velocity': True, 'id': 76693}, {'start_date': '2016-01-18', 'end_date': '2016-01-30', 'url': '/projects/development16/iteration/76694', 'locked': False, 'default_iteration': False, 'name': 'Frodo', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 26, 'include_in_velocity': True, 'id': 76694}, {'start_date': '2016-01-04', 'end_date': '2016-01-16', 'url': '/projects/development16/iteration/76695', 'locked': False, 'default_iteration': False, 'name': 'Ewok', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 35, 'include_in_velocity': True, 'id': 76695}, {'start_date': '2015-12-21', 'end_date': '2016-01-02', 'url': '/projects/development16/iteration/76696', 'locked': False, 'default_iteration': False, 'name': 'Dexter Jettster', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 3, 'include_in_velocity': True, 'id': 76696}, {'start_date': '2015-12-07', 'end_date': '2015-12-19', 'url': '/projects/development16/iteration/76697', 'locked': False, 'default_iteration': False, 'name': 'Chewbacca', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 26, 'include_in_velocity': True, 'id': 76697}, {'start_date': '2015-11-23', 'end_date': '2015-12-05', 'url': '/projects/development16/iteration/76698', 'locked': False, 'default_iteration': False, 'name': 'Boss Nass', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 27, 'include_in_velocity': True, 'id': 76698}, {'start_date': '2015-11-09', 'end_date': '2015-11-21', 'url': '/projects/development16/iteration/76699', 'locked': False, 'default_iteration': False, 'name': 'Ackbar', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 31, 'include_in_velocity': True, 'id': 76699}, {'start_date': '2015-10-26', 'end_date': '2015-11-07', 'url': '/projects/development16/iteration/76700', 'locked': False, 'default_iteration': False, 'name': 'Han Solo', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 25, 'include_in_velocity': True, 'id': 76700}, {'start_date': '2015-10-12', 'end_date': '2015-10-24', 'url': '/projects/development16/iteration/76701', 'locked': False, 'default_iteration': False, 'name': 'Harry Potter', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 33, 'include_in_velocity': True, 'id': 76701}, {'start_date': '2015-09-28', 'end_date': '2015-10-10', 'url': '/projects/development16/iteration/76702', 'locked': False, 'default_iteration': False, 'name': 'Boba Fett', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 36, 'include_in_velocity': True, 'id': 76702}, {'start_date': '2015-09-14', 'end_date': '2015-09-26', 'url': '/projects/development16/iteration/76703', 'locked': False, 'default_iteration': False, 'name': 'Darth Vader', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 15, 'include_in_velocity': True, 'id': 76703}, {'start_date': '2015-08-31', 'end_date': '2015-09-12', 'url': '/projects/development16/iteration/76704', 'locked': False, 'default_iteration': False, 'name': 'Hellboy', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 15, 'include_in_velocity': True, 'id': 76704}, {'start_date': '2015-08-24', 'end_date': '2015-08-29', 'url': '/projects/development16/iteration/76705', 'locked': False, 'default_iteration': False, 'name': 'Old Man Sprint', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 3, 'include_in_velocity': True, 'id': 76705}, {'start_date': '2015-08-10', 'end_date': '2015-08-22', 'url': '/projects/development16/iteration/76706', 'locked': False, 'default_iteration': False, 'name': 'PO System Sprint 3', 'hidden': True, 'iteration_type': 1, 'detail': '', 'story_count': 14, 'include_in_velocity': True, 'id': 76706}, {'start_date': '2016-02-15', 'end_date': '2016-02-27', 'url': '/projects/development16/iteration/78153', 'locked': False, 'default_iteration': False, 'name': 'H', 'hidden': False, 'iteration_type': 1, 'detail': '', 'story_count': 0, 'include_in_velocity': True, 'id': 78153}]
上面是来自Slumber API调用的变量iter_list。
我正在尝试从Python 3.5中收集上述信息中的密钥。
for key, value in iter_list.items():
print(key)
它告诉我iter_list没有items()属性。
最终目标是在单独的dict或配置文件中提供密钥名称,以便在搜索功能中使用,而不必手动查看每个API调用中的密钥。
答案 0 :(得分:1)
您希望访问字典中列表中第一个(也是唯一的)元素的项目。
for key, value in iter_list[0].items():
print(key)
答案 1 :(得分:1)
iter_list
似乎是一个以字典作为第一个元素的列表。只需访问第一个元素,您就可以获得字典:
for key, value in iter_list[0].items():
print(key)