99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

urlretrieve下載函數怎么在python中使用-創新互聯

這篇文章主要介紹了urlretrieve下載函數怎么在python中使用,創新互聯成都網站設計公司小編覺得不錯,現在分享給大家,也給大家做個參考,一起跟隨創新互聯成都網站設計公司小編來看看吧!

創新互聯公司是專業的會寧網站建設公司,會寧接單;提供做網站、網站制作,網頁設計,網站設計,建網站,PHP網站建設等專業做網站服務;采用PHP框架,可快速的進行會寧網站開發網頁制作和功能擴展;專業做搜索引擎喜愛的網站,專業的做網站團隊,希望更多企業前來合作!

Python主要用來做什么

Python主要應用于:1、Web開發;2、數據科學研究;3、網絡爬蟲;4、嵌入式應用開發;5、游戲開發;6、桌面應用開發。

實驗環境:windows 7,anaconda 3(python 3.5),tensorflow(gpu/cpu)

函數介紹:所用函數為six.moves下的urllib中的函數,調用如下urllib.request.urlretrieve(url,[filepath,[recall_func,[data]]])。簡單介紹一下,url是必填的指的是下載地址,filepath指的是保存的本地地址,recall_func指的是回調函數,下載過程中會調用可以用來顯示下載進度。

實驗代碼:以下載cifar10的dataset和抓取斗魚首頁為例

下載cifar10的dataset,并解壓

from six.moves import urllib
import os
import sys
import tensorflow as tf
import tarfile
FLAGS = tf.app.flags.FLAGS#提取系統參數作用的變量
tf.app.flags.DEFINE_string('dir','D:/download_html','directory of html')#將下載目錄保存到變量dir中,通過FLAGS.dir提取
directory = FLAGS.dir#從FLAGS中提取dir變量
url = 'http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz'
filename = url.split('/')[-1]#-1表示分割后的最后一個元素
filepath = os.path.join(directory,filename)
if not os.path.exists(directory):
 os.makedirs(directory)
if not os.path.exists(filepath):
 def _recall_func(num,block_size,total_size):
 sys.stdout.write('\r>> downloading %s %.1f%%' % (filename,float(num*block_size)/float(total_size)*100.0))
 sys.stdout.flush()
 urllib.request.urlretrieve(url,filepath,_recall_func)
 print()
 file_info = os.stat(filepath)
 print('Successfully download',filename,file_info.st_size,'bytes')
tar = tarfile.open(filepath,'r:gz')#指定解壓路徑和解壓方式為解壓gzip
tar.extractall(directory)#全部解壓

urlretrieve下載函數怎么在python中使用

抓取斗魚首頁

from six.moves import urllib
import os
import sys
import tensorflow as tf
FLAGS = tf.app.flags.FLAGS#提取系統參數作用的變量
tf.app.flags.DEFINE_string('dir','D:/download_html','directory of html')#將下載目錄保存到變量dir中,通過FLAGS.dir提取
directory = FLAGS.dir#從FLAGS中提取dir變量
url = 'http://www.douyu.com/'
filename = 'douyu.html'#保存成你想要的名字,這里保存成douyu.html
filepath = os.path.join(directory,filename)
if not os.path.exists(directory):
 os.makedirs(directory)
if not os.path.exists(filepath):
 def _recall_func(num,block_size,total_size):
 sys.stdout.write('\r>> downloading %s %.1f%%' % (filename,float(num*block_size)/float(total_size)*100.0))
 sys.stdout.flush()
 urllib.request.urlretrieve(url,filepath,_recall_func)
 print()
 file_info = os.stat(filepath)#獲取文件信息
 print('Successfully download',filename,file_info.st_size,'bytes')#.st_size文件的大小,以字節為單位

以上就是創新互聯成都網站設計公司小編為大家收集整理的urlretrieve下載函數怎么在python中使用,如何覺得創新互聯成都網站設計公司網站的內容還不錯,歡迎將創新互聯成都網站設計公司網站推薦給身邊好友。

另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、網站設計器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

網站題目:urlretrieve下載函數怎么在python中使用-創新互聯
網站鏈接:http://www.yijiale78.com/article12/cdpcgc.html

成都網站建設公司_創新互聯,為您提供靜態網站用戶體驗建站公司動態網站關鍵詞優化網站制作

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都seo排名網站優化