我试图在 tweepy 中使用函数“update_profile_background_image”并得到错误:
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)
问题是:这个库在一个鸡蛋文件中,我如何解决这个问题?这是 tweepy 上的错误吗?
该功能是读取文件(图像)并通过 POST(http)发送到 twitter api。
错误发生在我尝试操作加载的图像的地方。
我所有的 .py 都配置为使用 utf-8 :
# -- coding: utf-8 --