【发布时间】:2022-01-06 06:52:20
【问题描述】:
在以下python代码中:
from pynput.mouse import Listener
coord = []
def click(x, y, button, pressed):
if pressed:
x = int(x)
y = int(y)
coord.append(x)
coord.append(y)
if len(coord) == 4:
print(coord)
return
with Listener(on_click = click) as Listener:
Listener.join()
我想做的是;
当coord 有 4 个元素时,代码将停止。
就像,当我点击两次时,这个If 会停止。
【问题讨论】:
-
您每次点击附加 2 个项目,您想附加
(x, y)。