0
ftp 사이트에서 zip 폴더를 검색하고 Python을 사용하여 로컬 컴퓨터에 저장하려고합니다 (이상적으로는 위치를 지정하고 싶습니다). 내 C에 저장 :).Python에서 FTP에서 Zip 폴더를 가져 오는 방법
아래의 코드는 FTP 사이트에 연결 한 다음 PyScripter 창에서 약 1000 줄의 무작위 문자처럼 보이는 무언가가 발생하지만 실제로 아무 것도 내 하드 드라이브에 다운로드되지 않습니다.
팁이 있습니까?
import ftplib
import sys
def gettext(ftp, filename, outfile=None):
# fetch a text file
if outfile is None:
outfile = sys.stdout
# use a lambda to add newlines to the lines read from the server
ftp.retrlines("RETR " + filename, lambda s, w=outfile.write: w(s+"\n"))
def getbinary(ftp, filename, outfile=None):
# fetch a binary file
if outfile is None:
outfile = sys.stdout
ftp.retrbinary("RETR " + filename, outfile.write)
ftp = ftplib.FTP("FTP IP Address")
ftp.login("username", "password")
ftp.cwd("/MCPA")
#gettext(ftp, "subbdy.zip")
getbinary(ftp, "subbdy.zip")