我試着去使用tweepy功能「update_profile_background_image」,並得到錯誤:的UnicodeDecodeError進口(tweepy)
Traceback (most recent call last):
File "XXX.py", line 1401, in <module>
psn_card.gen_twitter_bg(user_db)
File "XXX.py", line 972, in gen_twitter_bg
auth_api.update_profile_background_image(file)
File "build/bdist.linux-x86_64/egg/tweepy/api.py", line 346, in update_profile_background_image
headers, post_data = API._pack_image(filename, 800)
File "build/bdist.linux-x86_64/egg/tweepy/api.py", line 729, in _pack_image
body = '\r\n'.join(body)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x89 in position 0: ordinal not in range(128)
的問題是:這個LIB是一個egg文件裏面,我該如何解決這個問題? 這是tweepy上的錯誤嗎?
該功能是讀取文件(圖片)並通過POST(http)發送到twitter api。
錯誤發生在我嘗試操作加載圖像的地方。
我所有的.py都配置爲使用UTF-8:
# -- coding: utf-8 --
請更多信息。你對update_profile_background_image()的調用是什麼樣的?錯誤可能在那裏,我們還不能確定。 – naeg
可能有用的常用鏈接:http://docs.python.org/howto/unicode.html – Carpetsmoker