Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- cep="65081264"
- url = "http://cep.la/{}".format(cep)
- headers = {
- 'Accept': 'application/json',
- }
- try:
- response = requests.get(url, headers=headers)
- print(response.json())
- if response.status_code == 200:
- response.encoding = 'utf-8'
- json_response = response.json()
- uf = json_response["uf"]
- cidade = json_response["cidade"]
- bairro = json_response["bairro"]
- logradouro = json_response["logradouro"]
- print(uf)
- print(cidade)
- print(bairro)
- print(logradouro)
- except Exception as e:
- print(e)
Add Comment
Please, Sign In to add comment