需要在不下载所有文件的情况下从FTP连接处理文件。什么是FTP的等效“开放”方法,所以我可以打开文件的内容,将文件读入大型存储库文件,丢弃文件及其内容?
import ftplib
repofile = open('repofile.txt', 'w')
ftp = ftplib.FTP('severaddress', 'username', 'password')
ftp.cwd('directory/I/want')
filelist = ftp.nlst()
''' above line creates a list of the files to loop through'''
for file in filelist:
# open file, but don't download it
# write contents to repofile