python url 下載並保存
方法一:用urllib
import json
import urllib
url_model=‘{"version":"2","url":"http:\/\/20180803.oss-cn-shanghai.aliyuncs.com\/video\/frozen_inference_graph_2.pb","instruction":"8967"}‘
url_model_txt=json.loads(url_model)
url = url_model_txt[‘url‘]
print "downloading with urllib"
urllib.urlretrieve(url, "./3.pb")
方法二:
import json
import urllib2
url_model=‘{"version":"2","url":"http:\/\/20180803.oss-cn-shanghai.aliyuncs.com\/video\/frozen_inference_graph_2.pb","instruction":"8967"}‘
url_model_txt=json.loads(url_model)
url = url_model_txt[‘url‘]
f = urllib2.urlopen(url)
data = f.read()
with open("./2/frozen_inference_graph.pb", "wb") as code:
code.write(data)
方法三:
url_model=‘{"version":"2","url":"http:\/\/20180803.oss-cn-shanghai.aliyuncs.com\/video\/frozen_inference_graph_2.pb","instruction":"8967"}‘
url_model_txt=json.loads(url_model)
url = url_model_txt[‘url‘]
f = requests.get(url)
with open("./2.pb","wb") as code:
code.write(f.content)
python url 下載並保存