尝试在 pynput 中使用"Button.Left"时如何修复"AttributeError(name) from None"



我正在使用pynput并试图让鼠标点击,为此我从 pynput 导入:

from pynput.mouse import Button, Controller

然后在第 8 行,我这样做:

button = Button.Left

结果,我收到此错误:

Traceback (most recent call last):
  File "C:/FILEPATH.py", line 8, in <module>
button = Button.Left
      File "C:Program Files (x86)PythonPython37-32libenum.py", line 346, in __getattr__
raise AttributeError(name) from None
    AttributeError: Left

你知道我做错了什么,或者这里缺少什么吗?

仅查看文档,它应该使用小写l Button.left,而不是使用大写l Button.Left

最新更新