Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“;如何修复&x2018;1个位置参数,但给出了3个’;Python中的错误”;_Python_Python 3.x - Fatal编程技术网

“;如何修复&x2018;1个位置参数,但给出了3个’;Python中的错误”;

“;如何修复&x2018;1个位置参数,但给出了3个’;Python中的错误”;,python,python-3.x,Python,Python 3.x,TypeError:send_document()接受1个位置参数,但给出了3个 基本Telebot类中的send_document: 因此,如果您想使用它,您应该创建派生类并手动实现它。我能写什么??这个def send_document(self):raise NotImplemented(“send_document需要工作”)您应该使用send_message或编写从TeleBot派生的新类。send_document仅将self作为参数。因此,要正确传递参数,只需bot.send_do

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


基本Telebot类中的
send_document


因此,如果您想使用它,您应该创建派生类并手动实现它。

我能写什么??这个
def send_document(self):raise NotImplemented(“send_document需要工作”)
您应该使用
send_message
或编写从
TeleBot
派生的新类。send_document仅将
self
作为参数。因此,要正确传递参数,只需
bot.send_document()
bot
self
,这正好是一个参数)。但是正如@vurmux在他们的回答中所说的,它将再次中断,因为该方法没有在基类中实现,您需要从它继承并自己实现它。
import telebot

token = "8xxxxxxx7:AAElU-XhG1of3VaZMexdDIE-M2aY71CRIFk" 
bot = telebot.TeleBot(token)
bot.send_document(5xxxxxxx4, open(file.txt, 'rb'))
def send_document(self):
    raise NotImplemented("send_document needs work")