TypeError:worker() 接受 0 个位置参数,但给出了 1 个

2022-01-31 00:00:00 python python-3.x

问题描述

我正在尝试实现一个子类,但它会抛出错误:

I'm trying to implement a subclass and it throws the error:

TypeError: worker() 接受 0 个位置参数,但给出了 1 个

class KeyStatisticCollection(DataDownloadUtilities.DataDownloadCollection):
    def GenerateAddressStrings(self):
        pass    
    def worker():
        pass
    def DownloadProc(self):
        pass


解决方案

你的 worker 方法需要 'self' 作为参数,因为它是类方法而不是函数.添加它应该可以正常工作.

Your worker method needs 'self' as a parameter, since it is a class method and not a function. Adding that should make it work fine.

相关文章