- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
大家好!我正在使用 pyTelegramBotApi 编写 Telegram 机器人。这是我的代码:
import telebot
from telebot import apihelper
bot = telebot.TeleBot(TOKEN);
apihelper.proxy = {'https': 'socks5://154.221.21.197:10800'}
bot.polling()
当我尝试运行它时,出现错误:
2019-11-28 00:44:10,836 (util.py:66 PollingThread) ERROR - TeleBot: "AttributeError occurred, args=("'NoneType' object has no attribute 'format'",)
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 60, in run
task(*args, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 278, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 248, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 189, in get_updates
return _make_request(token, method_url, params=payload)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 49, in _make_request
request_url = base_url.format(token, method_name)
AttributeError: 'NoneType' object has no attribute 'format'
"
Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/bot/newbot.py", line 14, in <module>
bot.polling()
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 391, in polling
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 414, in __threaded_polling
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 79, in raise_exceptions
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\six-1.13.0-py3.7.egg\six.py", line 696, in reraise
raise value
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 60, in run
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 278, in __retrieve_updates
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 248, in get_updates
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 189, in get_updates
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 49, in _make_request
AttributeError: 'NoneType' object has no attribute 'format'
Process finished with exit code 1
这是什么问题以及如何解决这个问题?代理正在工作(尝试与应用程序连接),gunicorn、PySocks、pyTelegramBotAPI、requests、urllib3 最新版本已安装。
谢谢!
最佳答案
打开
...\Python3x\Lib\site-packages\pyTelegramBotAPI-3.6.6-py3.8.egg\telebot\apihelper.py
找到#49
行并对其进行注释。它可能不正确,但它有效
关于python - 远程机器人 : AttributeError: 'NoneType' object has no attribute 'format' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59083300/
我目前正在尝试定义函数,但遇到了这个错误。我只是想做一个简单的函数,用户输入 2 个数字,然后将它们相乘。也请尽可能简单地解释我做错了什么。 (我是菜鸟) def userinput(): w
使用IPtools python 包我试图查看 IP 地址是否在特定范围内。这是我的代码: for line in g: org= line.split("|")[0] ranges
输入 [['1','2','3'],['a','b','c'],['6','7','8'],['e','f','g']] 输出应该是: 1, 2, 3a, b, c6, 7, 8e, f, g Cod
我目前正在使用 lambda 使 tkinter 按钮依次执行两件事: def classManip(): cManip = tk.Toplevel() cManip.title
我正在学习Python,作为练习,我编写了一些代码来查找用户定义函数的导数。代码如下。 def fx(value, function): x = value return eval(f
使用 Django。我有以下模型: class Postagem(models.Model): id = models.AutoField(primary_key=True, editable=Fal
我正在尝试为给定的数据集选择重要的特征(或者至少了解哪些特征解释更多的变异性)。为此,我使用 ExtraTreesClassifier 和 GradientBoostingRegressor - 然后
刚刚获得了SDXL模型的访问权限,希望为即将发布的版本进行测试...不幸的是,我们当前用于我们服务的代码似乎不能与稳定ai/稳定-扩散-xl-base-0.9一起工作,我不完全确定SDXL有什么不同,
通常,当我尝试使用BeautifulSoup解析网页时,BeautifulSoup函数会得到NONE结果,否则就会引发AttributeError。。以下是一些独立的(即,由于数据是硬编码的,不需要访
通常,当我尝试使用BeautifulSoup解析网页时,BeautifulSoup函数会得到NONE结果,否则就会引发AttributeError。。以下是一些独立的(即,由于数据是硬编码的,不需要访
我想遍历可迭代列表,但要求某些元素的类型可以是 None。 这看起来像这样: none_list = [None, [0, 1]] for x, y in none_list: print("
我得到object is not subscriptable在非空查询结果上。当我打印时 c.fetchone()它打印了正确的结果,但是当我检查类型时它显示 import sqlite3 conn
我在第 15 行收到此错误,但我不明白为什么。有任何想法吗?看来属性已经明确定义了,所以我完全不知所措。任何帮助将非常感激。AttributeError:“NoneType”对象没有属性“Sheets
我尝试对 Chrome WebDriver 进行子类化以包含一些初始化和清理代码,但随后 Python 提示创建的对象设置为 None: import glob import selenium imp
这个问题已经有答案了: Why do I get AttributeError: 'NoneType' object has no attribute 'something'? (10 个回答) 已关
这个问题已经有答案了: Why does the print function return None? (1 个回答) 已关闭 6 年前。 我对 Python 还很陌生。我正在制作一个生成器,可以为
我正在尝试比较两个表( table_a 和 table_b )并减去 table_a 的最后一列从table_b的最后一列开始。但是,table_a 包含一个额外的行,导致我得到 NoneType错误
当“文件名”是一个存在的文件时,这段代码运行良好……但是当它不存在时……我不断收到同样的错误:TypeError: 'NoneType' 对象不可迭代 (Errno 2) 尽管我从不迭代任何东西,除非
我在下面的代码中收到“NoneType”对象不可迭代的 TypeError。下面的代码用于使用 pyautogui 滚动 digits 文件夹中的 10 张图像(命名为 0 到 9,以图像中的 # 命
我有一段代码表现得很奇怪。 一开始,我导入了一个模块,它是 C 库的 python 绑定(bind)。 try: import pyccn except: print "ERROR:
我是一名优秀的程序员,十分优秀!