有人能看到这里的问题所在吗?我是python的新手,需要一些指导。我在装有Lion的mac上以32位模式运行Python 2.7.3。依赖项包括
pyOSC pyserial 2.6 python-xbee-api 2.00 optparse_gui 0.2 wxPython 2.8
如果有任何帮助,我将不胜感激!
OSCServer: KeyError on request from home.gateway:60537: 0
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 638, in __init__
self.handle()
File "/Library/Python/2.7/site-packages/OSC.py", line 1770, in handle
self._unbundle(decoded)
File "/Library/Python/2.7/site-packages/OSC.py", line 1761, in _unbundle
self._unbundle(msg)
File "/Library/Python/2.7/site-packages/OSC.py", line 1752, in _unbundle
self.replies += self.server.dispatchMessage(decoded[0], decoded[1][1:], decoded[2:], self.client_address)
File "/Library/Python/2.7/site-packages/OSC.py", line 1714, in dispatchMessage
reply = self.callbacks[addr](pattern, tags, data, client_address)
File "minihiveosc.py", line 74, in handler_output
self.setOutput( args[0], args[1:] )
File "minihiveosc.py", line 178, in setOutput
self.hive.oscToMiniBee( mid, data )
File "minihiveosc.py", line 330, in oscToMiniBee
self.hive.bees[ nid ].send_output( self.hive.serial, data )
KeyError: 0发布于 2012-07-09 22:57:17
当您使用不在字典中的键进行字典查找时,最常见的是引发KeyError异常。在本例中,它看起来应该在最后一行上:
self.hive.bees[ nid ].send_output( self.hive.serial, data )..specifically,self.hive.bees[ nid ]部件。nid显然包含一个0值,而您的self.hive.bees字典中没有0键。
https://stackoverflow.com/questions/11397591
复制相似问题