您可以使用它after()来定期获取鼠标坐标并更新标签。下面是一个例子:import tkinter as tkimport win32apiroot = tk.Tk()mousecords = tk.Label(root)mousecords.place(x=0, y=0)def show_mouse_pos(): x, y = win32api.GetCursorPos() #x, y = mousecords.winfo_pointerxy() # you can also use tkinter to get the mouse coords mousecords.config(text=f'x : {x}, y : {y}') mousecords.after(50, show_mouse_pos) # call again 50ms latershow_mouse_pos() # start the update taskroot.mainloop()