screenGrab()获取0位置参数,但给出了1

时间:2017-11-23 17:08:48

标签: python procedural-programming

我写了以下内容:

screenState = screenGrab(workingDirectory + '/Screenshots')

调用此子例程:

def screenGrab(directory):
    """
    Takes a screenshot of an area of the screen.

    :params:
        directory : directory to save screenshot in
    """

    box = (x_pad + 1, y_pad + 1, x_pad + 961, y_pad + 641)
    im = ImageGrab.grab(box)
    im.save(directory + '/full_snap__' + str(int(time.time())) + '.png', 'PNG')

当我尝试运行代码时,我收到以下错误:

TypeError: screenGrab() takes 0 positional arguments but 1 was given

我不确定为什么会发生这种错误。

1 个答案:

答案 0 :(得分:0)

对,愚蠢的错误。事实证明我有两个具有相同功能的相同名称的文件(一个是.pyw而另一个是.py)导入调用了错误的文件。