如何从“无”修复“AttributeError(name)”

问题描述 投票:-1回答:1

我正在使用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)\Python\Python37-32\lib\enum.py", line 346, in __getattr__
raise AttributeError(name) from None
    AttributeError: Left

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

(我使用pycharm IDE)

python attributeerror getattribute pynput
1个回答
1
投票

只是看看the docs,它应该是Button.left与小写l而不是Button.Left与大写l

© www.soinside.com 2019 - 2024. All rights reserved.