Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:ftp文件卡在缓冲区中?_Python_Ftp - Fatal编程技术网

Python:ftp文件卡在缓冲区中?

Python:ftp文件卡在缓冲区中?,python,ftp,Python,Ftp,使用此方法下载带有ftplib的文件时: ftp = ftplib.FTP() ftp.connect("host", "port") ftp.login("user", "pwd") size = ftp.size('locked') def handleDownload(block): f.write(block) pbar.update(pbar.currval+len(block)) f = open("locked", "wb") pbar=ProgressBar(

使用此方法下载带有ftplib的文件时:

ftp = ftplib.FTP()
ftp.connect("host", "port")
ftp.login("user", "pwd")
size = ftp.size('locked')

def handleDownload(block):
    f.write(block)
    pbar.update(pbar.currval+len(block))

f = open("locked", "wb")
pbar=ProgressBar(widgets=[FileTransferSpeed(), Bar('>'), ' ', ETA(), ' ',    ReverseBar('<'), Percentage()],     maxval=size).start()
ftp.retrbinary("RETR locked",handleDownload, 1024)
pbar.finish()
ftp=ftplib.ftp()
ftp.connect(“主机”、“端口”)
ftp.login(“用户”、“pwd”)
size=ftp.size('锁定')
def手动卸载(块):
f、 写入(块)
pbar.update(pbar.currval+len(块))
f=打开(“锁定”、“wb”)

pbar=ProgressBar(widgets=[FileTransferSpeed(),Bar('>'),'',ETA(),'',ReverseBar('正如Wooble在评论中所说的那样,我没有像白痴一样关闭()文件。它解决了这个问题。

我认为问题可能是你从来没有关闭文件,而不是缓冲ftp。你有一个有效的观点,我将尝试它。