# -*- coding: utf-8 -*-
import urllib.request, json

url = 'http://apis.baidu.com/netpopo/illegaladdr/coord?lat=31.3004088721&lng=121.4849729860&range=2000&num=10'
add_header= {"apikey":"9a1bfb513e18XXXXXf48314508e"}
req = urllib.request.Request(url,headers=add_header)
resp = urllib.request.urlopen(req)
content = resp.read().decode('utf-8') 
#不用.decode('utf-8')会报错the JSON object must be str, not 'bytes'
res = json.loads(content)
if(res):
    print(res)

 

相关文章:

  • 2022-02-04
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-11-01
猜你喜欢
  • 2022-12-23
  • 2022-03-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2021-06-17
相关资源
相似解决方案