如何修复“ AttributeError(name)from None”

时间:2019-04-05 06:07:54

标签: python attributeerror getattribute pynput

我正在使用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)

1 个答案:

答案 0 :(得分:1)

仅查看the docs,它应该是const originalObj = { id: 1, name: 'originalObj' } const newObj = { newId: 2, name: 'newObj' } originalObj = { ...originalObj, newObj } ,其小写字母Button.left,而不是l,其大写字母Button.Left