我试图解析推特数据。我检索了数据并将其存储在一个名为“ twitterdata ”的文件中
f = open('twitterdata','r')
for line in f:
jsonline = json.loads(line)
for key in jsonline:
print str(jsonline[key]).encode('utf-8')
即使在使用encode('utf-8')后,我也会收到错误消息:
print str(jsonline[key]).encode('utf-8')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-17: ordinal not in range(128)