微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Tkinter 回调中的异常 |密钥错误:0

如何解决Tkinter 回调中的异常 |密钥错误:0

我找不到任何解决我的问题的方法。首先是有问题的代码

r = StringVar()
r.set("xx")

xx = Radiobutton(frame2,variable=r,value="x")
xx.grid(row=3,column=1,pady=10,padx=10)
Star = Label(frame2,text="xxx")
Star.grid(row=3,column=0)
qq = Radiobutton(frame2,value="q")
qq.grid(row=4,column=1)
Label2 = Label(frame2,text="xxx")
Label2.grid(row=4,column=0)

如果点击qq-Radiobutten,程序运行完美。 如果单击 xx-Radiobutton,程序将返回以下错误

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\python37\site-packages\pandas\core\indexes\base.py",line 3080,in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas\_libs\index.pyx",line 70,in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\index.pyx",line 101,in pandas._libs.index.IndexEngine.get_loc
  File "pandas\_libs\hashtable_class_helper.pxi",line 4554,in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas\_libs\hashtable_class_helper.pxi",line 4562,in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py",line 1705,in __call__
    return self.func(*args)
  File "C:\Users\xxx\xxx\xxx\xxx.py",line 1644,in xxx
    Produktname = Search[0][4]
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\python37\site-packages\pandas\core\frame.py",line 3024,in __getitem__
    indexer = self.columns.get_loc(key)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\python37\site-packages\pandas\core\indexes\base.py",line 3082,in get_loc
    raise KeyError(key) from err
KeyError: 0

有人可以指出我的错误吗?

PS.:代码运行完美,直到我今天更新了 Sublime Text。

谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。