Skip to main content
 首页 » 编程设计

python之属性错误 : 'Twython' object has no attribute 'destroy_message'

2025年05月04日9mate10pro

在过去 2 周左右的时间里,我的一个 Twitter 清理脚本停止工作了。似乎不再有用于删除已发送 DM 的 destroy_message 属性。这是删除还是重命名?这是我的代码和错误。

for tweet in tweets: 
           print "Deleting: " + tweet["text"] 
           result = self._api.destroy_message(id = tweet["id"]) 

这里是错误:

Getting sent DMs.... 
Deleting: Sure no problem 
Traceback (most recent call last): 
 
File "scrub_twitter.py", line 127, in <module> 
obj.delete_sent_dms() 
File "scrub_twitter.py", line 102, in delete_sent_dms 
result = self._api.destroy_message(id = tweet["id"]) 
AttributeError: 'Twython' object has no attribute 'destroy_message' 

请您参考如下方法:

是的,它已重命名为:

destroy_direct_message(**params) 

See here.