久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Python:從 FTP 服務(wù)器下載文件

Python: download a file from an FTP server(Python:從 FTP 服務(wù)器下載文件)
本文介紹了Python:從 FTP 服務(wù)器下載文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試下載一些公共數(shù)據(jù)文件.我截屏以獲取文件的鏈接,它們看起來都像這樣:

I'm trying to download some public data files. I screenscrape to get the links to the files, which all look something like this:

ftp://ftp.cdc.gov/pub/Health_Statistics/NCHS/nhanes/2001-2002/L28POC_B.xpt

我在 Requests 庫網(wǎng)站上找不到任何文檔.p>

I can't find any documentation on the Requests library website.

推薦答案

requests 庫不支持 ftp 鏈接.

requests library doesn't support ftp links.

要從 FTP 服務(wù)器下載文件,您可以:

To download a file from FTP server you could:

import urllib 

urllib.urlretrieve('ftp://server/path/to/file', 'file')
# if you need to pass credentials:
#   urllib.urlretrieve('ftp://username:password@server/path/to/file', 'file')

或者:

import shutil
import urllib2
from contextlib import closing

with closing(urllib2.urlopen('ftp://server/path/to/file')) as r:
    with open('file', 'wb') as f:
        shutil.copyfileobj(r, f)

Python3:

import shutil
import urllib.request as request
from contextlib import closing

with closing(request.urlopen('ftp://server/path/to/file')) as r:
    with open('file', 'wb') as f:
        shutil.copyfileobj(r, f)

這篇關(guān)于Python:從 FTP 服務(wù)器下載文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Why I cannot make an insert to Python list?(為什么我不能插入 Python 列表?)
Insert a column at the beginning (leftmost end) of a DataFrame(在 DataFrame 的開頭(最左端)插入一列)
Python psycopg2 not inserting into postgresql table(Python psycopg2 沒有插入到 postgresql 表中)
list extend() to index, inserting list elements not only to the end(list extend() 索引,不僅將列表元素插入到末尾)
How to add element in Python to the end of list using list.insert?(如何使用 list.insert 將 Python 中的元素添加到列表末尾?)
TypeError: #39;float#39; object is not subscriptable(TypeError:“浮動對象不可下標)
主站蜘蛛池模板: 欧美国产日韩在线 | 中文av字幕| 久久久久久九九九九九九 | 91日韩在线 | 久久国产精品色av免费观看 | 精品久久久久久久久久久久久久 | 午夜www | 中文字幕 欧美 日韩 | 青青草综合 | 国产亚洲精品a | 精品国产高清一区二区三区 | www国产成人免费观看视频 | 国产精品中文字幕在线 | 国产亚洲精品久久久久动 | 激情六月丁香婷婷 | 不卡在线视频 | 黄视频国产| 欧美一区二区三区久久精品 | 亚洲欧洲综合av | 精品福利视频一区二区三区 | 国产一区二区精品 | 99精品电影 | 91精品国产综合久久久久 | 男女啪啪高潮无遮挡免费动态 | 91社影院在线观看 | 亚洲一区二区综合 | 成人av一区 | 91精品国产综合久久久久 | 国产一区视频在线 | 在线看av的网址 | 久久久久久久一区 | 91免费福利视频 | 亚洲天堂网站 | 亚洲欧美精品在线观看 | 日韩在线| 久久在线视频 | 亚洲国产精品久久久 | 久久久www成人免费无遮挡大片 | 欧美在线网站 | 久热精品视频 | 精品一二三区 |