我有这个字符串Traor\u0102\u0160
Traor\u0102\u0160
应该生产Traoré
。然后Traoré
utf-8 解码应该产生Traorè
我怎样才能将其转换为Traorè
?
什么样的字符是Traor\u0102\u0160
?统一码?
我已经多次阅读此http://docs.python.org/howto/unicode.html#encodings 。但我仍然很困惑。
我通过以下请求获得此数据:
import json
import requests
# making a request to get this json
r = requests.get('http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/web/199074.json')
print r.json
解决方案
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import json
import requests
headers = {'Content-Type': 'application/json'}
r = requests.get('http://cdn.content.easports.com/fifa/fltOnlineAssets/2013/fut/items/web/199074.json', headers=headers)
print r.content
#prints
{"Item":{"FirstName":"Lacina","LastName":"Traoré","CommonName":null,"Height":"203","DateOfBirth":{"Year":"1990","Month":"8","Day":"20"},"PreferredFoot":"Left","ClubId":"100766","LeagueId":"67","NationId":"108","Rating":"78","Attribute1":"79","Attribute2":"71","Attribute3":"45","Attribute4":"69","Attribute5":"50","Attribute6":"72","Rare":"1","ItemType":"PlayerA"}}
基本上我需要设置发送正确的标题。
谢谢你们