有时,FTP服务器会在文件完全下载之前关闭连接。。你知道吗
这是我的密码:
ftp = ftplib.FTP(site)
ftp.login(user, pw)
ftp.cwd(dir)
remotefiles = ftp.nlst()
for file in remotefiles:
if fnmatch.fnmatch(file, match_text):
if os.path.exists(file):
if True: print file, 'already fetched'
else:
if True: print 'Downloading', file
local = open(file, 'wb')
try:
ftp.retrbinary('RETR ' + file, local.write)
finally:
local.close()
if True: print 'Download done.'
您可以在
FTP
构造函数中指定一个timeout
参数,并将其设置为0或一些非常大的值,如系统最大值。你知道吗此外,您可以打开调试来查看幕后的情况。你知道吗
希望这有帮助。你知道吗
相关问题 更多 >
编程相关推荐