1
from urllib.request import urlopen
from urllib.parse import quote
import string
import json
url = 'http://api.map.baidu.com/telematics/v3/weather?location=%E9%83%91%E5%B7%9E%E5%B8%82&output=json&ak=TueGDhCvwI6fOrQnLM0qmXxY9N0OkOiQ&callback=?'
urlopen返回的是http:client.HTTPResponse类文件对象
response = urlopen(quote(url,safe = string.printable)
#url不支持中英文混写 之所以我们可以看到中文 是因为浏览器处于用户友好的目的
#quote对url进行解析但是在url执行的时候中文会进行转码 如果不进行转码程序会报错
#quote转码的时候 不但会对中文进行转码 同时也会对特殊符号进行转码 如果不想让这些特殊符号
#进行转码 就使用安全转码 只会转码中文
responsedata = response.read()
对文件进行读操作
responsejson = json.loads()