“;如何修复&x2018;1个位置参数,但给出了3个’;Python中的错误”;
TypeError:send_document()接受1个位置参数,但给出了3个“;如何修复&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
基本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")