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

如何使用 Python ftplib 通過 FTP 下載文件

How to download a file via FTP with Python ftplib(如何使用 Python ftplib 通過 FTP 下載文件)
本文介紹了如何使用 Python ftplib 通過 FTP 下載文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

I have the following code which easily connects to the FTP server and opens a zip file. I want to download that file into the local system. How to do that?

# Open the file for writing in binary mode
print 'Opening local file ' + filename
file = open(filename, 'wb')

# Download the file a chunk at a time
# Each chunk is sent to handleDownload
# We append the chunk to the file and then print a '.' for progress
# RETR is an FTP command

print 'Getting ' + filename
ftp.retrbinary('RETR ' + filename, handleDownload)

# Clean up time
print 'Closing file ' + filename
file.close()

解決方案

handle = open(path.rstrip("/") + "/" + filename.lstrip("/"), 'wb')
ftp.retrbinary('RETR %s' % filename, handle.write)

這篇關于如何使用 Python ftplib 通過 FTP 下載文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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:“浮動對象不可下標)
主站蜘蛛池模板: 成人免费视频视频 | 99精品久久久 | 黄色在线观看免费 | 乳色吐息樱花 | 三级在线播放 | 四虎影院在线播放 | 国产一区二区影院 | 伊人av综合 | 欧美日本在线 | 久久中文字幕视频 | 久久精品久久久精品美女 | 日韩免费观看视频 | 亚洲国产欧美日韩 | 精品国产成人 | 黄色小说视频网站 | 婷婷久久五月天 | av免费网站 | 久久伊人久久 | 亚洲va韩国va欧美va精品 | 黄色一级片视频 | 日韩理论在线 | 性视频在线 | 亚洲不卡| 国产激情一区二区三区 | 亚洲精品久久 | 美女久久久久久 | 久久精品欧美一区二区 | 欧美国产综合 | 永久免费av网站 | 一区久久 | 日本www色 | 欧美日韩一区二区三区 | 亚洲乱色| 97在线播放 | 久热精品视频在线观看 | 日韩免费精品视频 | 国产不卡在线观看 | 99精品国产一区二区 | 免费看黄色小视频 | 国产91在线播放 | 九九热在线播放 |