按照书上描述麻了如下代码,居然报错了,报错了,报错了。一直百度不得其解,故上来问问大神
系统是osX,该下的模块以及依赖包都下好,就是有问题。
代码如下:
import pyautogui, time
time.sleep(5)
pyautogui.click()
distance = 200
while distance >0:
pyautogui.dragRel(distance, 0, duration=0.2)
distance = distance - 5
pyautogui.dragRel(0, distance, duration=0.2)
pyautogui.dragRel(-distance, 0, duration=0.2)
distance = distance - 5
pyautogui.dragRel(0, -distance, duration=0.2)
报错如下
Traceback (most recent call last):
File "/Users/jibohe/exercise.py", line 11, in <module>
pyautogui.dragRel(distance,0,duration=0.2)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyautogui/__init__.py", line 944, in dragRel
_mouseMoveDrag('drag', mousex, mousey, xOffset, yOffset, duration, tween, button)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyautogui/__init__.py", line 1053, in _mouseMoveDrag
platformModule._dragTo(tweenX, tweenY, button)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyautogui/_pyautogui_osx.py", line 436, in _dragTo
assert False, "button argument not in ('left', 'middle', 'right')"
AssertionError: button argument not in ('left', 'middle', 'right')