You need to encode your output.
If I were you I'll use python3, since python2 encoding is a headache. Anyways I made a super encoding function to help you:
def encode_dict(dic, encoding='utf-8'):
new_dict={}
for key, value in dic.items():
new_key=key.encode(encoding)
if isinstance(value, list):
new_dict[new_key]=[]
for item in value:
if isinstance(item, unicode):
new_dict[new_key].append(item.encode(encoding))
elif isinstance(item, dict):
new_dict[new_key].append(decode_dict(item))
else:
new_dict[new_key].append(item)
elif isinstance(value, unicode):
new_dict[new_key]=value.encode(encoding)
elif isinstance(value, dict):
new_dict[new_key]=decode_dict(value)
return new_dict
So you do: self.wfile.write(encode_dict(r.json()))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…