Home>

If the code here (https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11164547096) is executed in Python3 as it is
UnicodeDecodeError:'utf-8'codec can't decode byte 0x89 in position0: invalid start byte
How do I change it?

import base64
from requests_oauthlib import OAuth1Session
import json
CK = '' # Consumer Key
CS = '' # Consumer Secret
AT = '' # Access Token
AS = '' # Accesss Token Secert
oauth = OAuth1Session (CK, CS, AT, AS)
url = 'https://api.twitter.com/1.1/account/update_profile_image.json'
data = open ('image.png', 'rt'). read ()
data = base64.b64encode (data)
params = {'image': data}
res = oauth.post (url, params = params)