我使用 twitter 收集推文时出错 API

Errors when I collect tweets using twitter API

我正在使用 tweetminer 从该站点收集推文: https://github.com/kshaffer/tweetmineR

但是当我 运行 使用 twitter_search.py 进行搜索时 我收到这些错误:

<undefined>
'charmap' codec can't encode character '\u06cc' in position 196: character maps to <undefined>
'charmap' codec can't encode character '\U0001f43c' in position 88: character maps to <undefined>
'charmap' codec can't encode character '\u06cc' in position 210: character maps to <undefined>

它们不完全是错误,但搜索将继续。但是其中有很多打印在控制台上。如何解决?

你可以尝试在每次使用open()时添加参数encoding='utf-8'(第41和48行)。或者将 .encode('utf-8') 应用于您收集的推文。