2
I’m studying Requests in Python and I’m trying to get the data from the zip code: http://api.postmon.com.br/v1/cep/
I can pick up, but when it comes time to show them, how I live in São Paulo because of the encoding I get: S\u00e3o Paulo
Reading the requests tab (http://docs.python-requests.org/pt_BR/latest/user/quickstart.html#respota-json) I know it’s possible to fix it using r.encoding, but I’m not getting it. What I’m doing wrong?
import requests
CEP = 'http://api.postmon.com.br/v1/cep/'+ '01001001'
r = requests.get(CEP)
r.encoding = 'ISO-8859-1'
print r.text
Upshot:
{"complement": "lado par", "bairro": "S u00e9", "cidade": "S u00e3o Paulo", "logradouro": "Pra u00e7a da S u00e9", "estado_info": {"area_km2": "248.221,996", "codigo_ibge": "35", "name": "S u00e3o Paulo"}, "cep": "01001001", "cidade_info": {"area_km2": "1521,11", "codigo_ibge": "3550308"}, "estado": "SP"}
Very good tip! + 1
– Guilherme Nascimento