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

Python:從 FTP 服務器下載文件

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

問題描述

我正在嘗試下載一些公共數(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 服務器下載文件,您可以:

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)

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

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(liá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网站在线播放 | 一级做a| 久久激情视频 | 欧美二区三区 | 欧美日韩一区二区在线 | 91资源在线| 成人精品久久日伦片大全免费 | 91性高湖久久久久久久久_久久99 | 综合网伊人| 99re6在线视频精品免费 | 中文字幕一区二区三区精彩视频 | 欧美成人激情 | 免费国产一区二区 | 久久久精品久久 | 国产精品久久久久久久久婷婷 | 国产免费一区二区 | 色综合av | 精品视频久久久久久 | 久久精品一区二区三区四区 | 欧美男人天堂 | 精品国产乱码久久久久久丨区2区 | 一区二区三区高清 | 中文字幕综合 | 成人免费黄色片 | 国产精品久久久久aaaa九色 | 久久精品久久久 | 国产一区二区三区在线 | 久久一区二区三区电影 | 91传媒在线播放 | 亚洲激情在线观看 | 国产精品theporn| 亚洲精品一区二三区不卡 | 国产精品一区二区福利视频 | 红色av社区 | 色片在线观看 | 亚洲一二三区在线观看 | 久久精品国产a三级三级三级 | 欧美日韩精品在线一区 | 一区二区精品 | 免费av在线网站 |