0

我有这个 python 代码的 Keyerror

service = self.get_cd_service()
browse_response = service.Browse(ObjectID=str(object_id),
                                 BrowseFlag=browse_flag,
                                 Filter=filter,
                                 StartingIndex=starting_index,
                                 RequestedCount=requested_count,
                                 SortCriteria=sort_criteria)
elt = Element.from_string(browse_response['Result'])
browse_response['Result'] = elt.get_items()
return browse_response

错误是:

Traceback (most recent call last):
  File "CommandlLineControlPointAv.py", line 93, in <module>
    main()
  File "CommandlLineControlPointAv.py", line 89, in main
    cmdline.run()
  File "CommandlLineControlPointAv.py", line 68, in run
    self.cmd_browse(c.split(' ')[1])
  File "CommandlLineControlPointAv.py", line 48, in cmd_browse
    result = self.browse(id, 'BrowseDirectChildren', '*', 0, 10)['Result']
  File "/usr/local/lib/python2.7/dist-packages/brisa/upnp/control_point/control_point_av.py", line 136, in browse
    elt = Element.from_string(browse_response['Result'])
KeyError: 'Result'

感谢您的帮助/最好的问候。

雷姆

4

1 回答 1

3

browse_response 没有密钥Result检查 browse_reponse 包含的内容

service.Browse您可以在通话 后立即放入调试器import pdb; pdb.set_trace()

您可以broser_response通过 python日志记录该对象

于 2013-02-05T16:10:34.623 回答