python-推特错误 api.PostDirectMessage
python-twitter error with api.PostDirectMessage
我正在测试 python-twitter 的代码,在我尝试将其发送到 post 直接发送给 id 的消息之前,一切似乎都还不错。
api.PostDirectMessage(3517181843, "some text test")
然后returns
Traceback (most recent call last):
File "c:/Users/Azizah Blackwood/Documents/GitHub/just-a-chatbot-test/chatbotwithdifferentlib.py", line 11, in <module>
api.PostDirectMessage(3517181843, "some text test")
File "C:\Users\Azizah Blackwood\AppData\Local\Programs\Python\Python37-32\lib\site-packages\twitter\api.py", line 3044, in PostDirectMessage
created_at=data['event']['created_timestamp'],
KeyError: 'event'
我的意思是返回给你的数据是一个空字典或者字典没有那个元素。
data = {}
print(data['event']['created_timestamp'])
你会得到KeyError: 'event'
您可以尝试传入 return_json=True
并查看实际响应:
print(api.PostDirectMessage(3517181843, "some text test", return_json=True))
我正在测试 python-twitter 的代码,在我尝试将其发送到 post 直接发送给 id 的消息之前,一切似乎都还不错。
api.PostDirectMessage(3517181843, "some text test")
然后returns
Traceback (most recent call last):
File "c:/Users/Azizah Blackwood/Documents/GitHub/just-a-chatbot-test/chatbotwithdifferentlib.py", line 11, in <module>
api.PostDirectMessage(3517181843, "some text test")
File "C:\Users\Azizah Blackwood\AppData\Local\Programs\Python\Python37-32\lib\site-packages\twitter\api.py", line 3044, in PostDirectMessage
created_at=data['event']['created_timestamp'],
KeyError: 'event'
我的意思是返回给你的数据是一个空字典或者字典没有那个元素。
data = {}
print(data['event']['created_timestamp'])
你会得到KeyError: 'event'
您可以尝试传入 return_json=True
并查看实际响应:
print(api.PostDirectMessage(3517181843, "some text test", return_json=True))