【发布时间】:2013-10-29 08:26:09
【问题描述】:
我一直在想办法解决这个错误。这是我第一次遇到这样的错误。我在 Google 上进行了全面搜索,但找不到解决此问题的方法。
Traceback (most recent call last):
File "C:\Users\Parent\Desktop\NEW PROJECT\code testing and practice.py", line 49, in <module>
print startGame()
File "C:\Users\Parent\Desktop\NEW PROJECT\code testing and practice.py", line 30, in startGame
mousePos(304, 197)
TypeError: mousePos() takes exactly 1 argument (2 given)
def leftClick():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
print "Click."
def leftDown():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.1)
print 'left Down'
def leftUp():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
time.sleep(.1)
print 'left release'
这是我的错误:
def mousePos(cord):
win32api.SetCursorPos(x_pad + cord[0], y_pad + cord[1])
def get_cords():
x,y = win32api.GetCursorPos()
x = x - x_pad
y = y - y_pad
print x,y
def startGame():
#location of first menu
mousePos(304, 197)
leftClick()
time.sleep(.1)
#location of second menu
mousePos(338, 394)
leftClick()
time.sleep(.1)
#location of third menu
mousePos(576, 453)
leftClick()
time.sleep(.1)
#location of fourth menu
mousePos(311, 397)
leftClick()
time.sleep(.1)
print startGame()
【问题讨论】:
-
错误告诉你'def mousePos(cord)`接受一个参数
cord,而你传递两个mousePos(311, 397)。
标签: function python-2.7 typeerror