类型错误:worker() 采用 0 个位置参数,但给出了 1 个 [英] TypeError: worker() takes 0 positional arguments but 1 was given

查看:63
本文介绍了类型错误:worker() 采用 0 个位置参数,但给出了 1 个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于类型错误:worker() 采用 0 个位置参数,但给出了 1 个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆