Python错误。pos列表

2024-04-23 18:51:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我有几个python错误,我不知道如何修复它们。在

谢谢。在

所有错误列表:

    Traceback (most recent call last):
  File "C:\Users\----\Desktop\wm3con-master\wm3con-master\wm3con.py", line 277,
in <module>
    sys.exit(main())
  File "C:\Users\----\Desktop\wm3con-master\wm3con-master\wm3con.py", line 274,
in main
    return curses.wrapper(app.run_curses_app)
  File "C:\Python32\lib\curses\wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "C:\Users\----\Desktop\wm3con-master\wm3con-master\wm3con.py", line 230,
in run_curses_app
    m.set_data(self.data)
  File "C:\Users\----\Desktop\wm3con-master\wm3con-master\wm3con.py", line 114,
in set_data
    dets = data.get('detections', [])
AttributeError: 'NoneType' object has no attribute 'get'

编辑:.py文件下面的代码(从2转换为3)这是不起作用的东西 我不知道你们说的数据是什么意思。在

这是f-secures世界地图ASCII版。我把它从第二版改成了第三版。在

.py文件的代码如下:

^{pr2}$

Tags: inpymasterappdatareturnmain错误
2条回答

dataNone。你应该检查一下你是怎么得到的,为什么是None。在

您的数据加载过程似乎失败了(例如引发异常),而您当前的代码被设置为忽略。在第一次尝试加载数据时发生这种情况时,应用程序的data属性在初始化后仍保留None。当它稍后试图将此传递给其他代码时,它会导致您看到的错误。在

以下是导致错误的关键代码:

class MapApp(object):
    def __init__(self, conf=None):
        self.data = None # self.data is initially None

    def fetch_data(self, epoch_now, force_refresh=False):
        try:
            self.data = json.load(urllib.request.urlopen(self.stream_url))
            self.last_fetch = epoch_now
        except Exception: # exceptions from the json or urllib code above are ignored
            pass

    def run_curses_app(self, scr):
        m = AsciiMap()
        while True:
            now = int(time.time())
            refresh = self.fetch_data(now) # this may fail silently
            m.set_data(self.data) # but if it does (the first time) this fails noisily

相关问题 更多 >