如何使用Tweepy以阿拉伯语文本作为查询使用Python来流式发送推文?

如何使用Tweepy以阿拉伯语文本作为查询使用Python来流式发送推文?,python,twitter,unicode,streaming,tweepy,Python,Twitter,Unicode,Streaming,Tweepy,我一直在尝试使用Tweepy来传输推文。当查询是英语时,它工作得很好,但当查询是阿拉伯语时,我无法让它工作。从前面的问题中,我尝试将twitterStream.filter(track=[u'اإاامية'])作为unicode,但出现了错误: In[36]: twitterStream.filter(track=[u'الإسلامية']) Traceback (most recent call last): File "C:\Python27\lib\site-packages\I

我一直在尝试使用Tweepy来传输推文。当查询是英语时,它工作得很好,但当查询是阿拉伯语时,我无法让它工作。从前面的问题中,我尝试将twitterStream.filter(track=[u'اإاامية'])作为unicode,但出现了错误:

In[36]: twitterStream.filter(track=[u'الإسلامية'])

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 3032, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-35-706cbc790f1e>", line 1, in <module>
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2978, in run_ast_nodes
    if self.run_code(code, result):
  File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 3049, in run_code
    self.showtraceback()
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5\helpers\pydev\pydev_ipython_console_011.py", line 144, in showtraceback
    import traceback;traceback.print_exc()
  File "C:\Python27\lib\traceback.py", line 233, in print_exc
    print_exception(etype, value, tb, limit, file)
  File "C:\Python27\lib\traceback.py", line 125, in print_exception
    print_tb(tb, limit, file)
  File "C:\Python27\lib\traceback.py", line 70, in print_tb
    if line: _print(file, '    ' + line.strip())
  File "C:\Python27\lib\traceback.py", line 13, in _print
    file.write(str+terminator)
  File "C:\Python27\lib\encodings\cp1252.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 34-42: character maps to <undefined>

尝试使用twitterStream.filter(track=[unicode(“utf-8”))

,而不是:

print status.text
return True
使用:

print status.text
return True
print('{}\t{}\t{}'.format(status.created_at,status.user.screen_name,status.text))