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 (将#修改为@)