1
import json
import urllib2
url='http://search.twitter.com/search.json?q=python'
open=urllib2.urlopen(url)
response=open.read().encode('utf8')
data=json.loads(response)
results=data['results']
for result in results:
print result['from_user'] + ': ' + result['text'] + '\n'
提供了錯誤UnicodeEncodeError: 'charmap' codec can't encode characters in position 16-24: character maps to <undefined>
。在Python 2.7的urllib2和JSON腳本引發的unicode錯誤
任何人都有解決方案嗎?
沒有解決我的問題。我已經使用了編碼('utf-8')。 – govindreddy
,我建議嘗試在我的回覆中使用「解碼」。 – udoprog