LYF511 发表于 2019-3-27 19:09:44

python报错

本帖最后由 LYF511 于 2019-3-27 19:11 编辑

咋回事呀?

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1702, in __call__
    return self.func(*args)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\program\tool.py", line 36, in explorer
    button = tk.Button(frame, text="确定", command=Yes)
UnboundLocalError: local variable 'Yes' referenced before assignment

相关代码:
def explorer(self):
      root = tk.Tk()
      frame = tk.Frame(root)
      frame.pack()

      e = tk.Entry(root)
      e.pack(padx=20, pady=20)

      button = tk.Button(frame, text="确定", command=Yes)
      button.pack()

      def Yes():
            os.startfile(e.get())

      root.geometry()

      root.title("请输入路径:")
      
      mainloop()

heidern0612 发表于 2019-3-27 20:05:22

UnboundLocalError: local variable 'Yes' referenced before assignment

未绑定本地变量错误:本地变量“yes”在赋值之前被调用。
页: [1]
查看完整版本: python报错