1
import pyautogui
import time

def pause():
    time.sleep(0.001)

while True:
    pyautogui.keyDown('down')


    time.sleep(5)

给我错误

C:\Python27\python.exe E:/Python/win32/pythongui.py
Traceback (most recent call last):
  File "E:/Python/win32/pythongui.py", line 1, in <module>
    import pyautogui
  File "E:\Python\win32\pyautogui.py", line 45, in <module>
    screenWidth, screenHeight = pyautogui.size()
AttributeError: 'module' object has no attribute 'size'

Process finished with exit code 1

我不明白为什么会出现这个错误,我什至没有调用属性大小,昨天一切正常。今天出于某种奇怪的原因,我不断收到此错误。pyautogui 工作时的代码与以前完全相同。

4

1 回答 1

1

因为您将文件名设置为 pyautogui.py,这显然与您导入的包冲突。更改文件名并再次运行参考此问题: https ://github.com/Microsoft/vscode-python/issues/1588

于 2019-08-21T01:06:14.590 回答