擅长:python、mysql、java
<p>实际上,您只需要附加一次x和y。你可以使追加发生在点击事件-无需循环!你知道吗</p>
<pre><code>from tkinter import *
import csv
root = Tk()
coords = []
def click(event):
global x,y
x, y= event.x,event.y
coords.append([x, y])
print("Clicked at: ", x, y)
frame = Frame(root, width=100, height=100)
frame.bind("<Button-1>", click)
frame.pack()
root.mainloop()
</code></pre>