使用python的ftp上的ConnectionResetError

时间:2018-08-17 18:17:26

标签: python python-3.x ftp

我有一个python程序,用于将以“ ABC”开头的文本文件名上载到sftp站点。我得到了:

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

这是我的代码

try:
    session = ftplib.FTP('ftp.aaa.com','usertest','pwd12')
    session.cwd('Test')
    print("Currently in:", session.pwd())

    for filename in glob.glob('C:/ABC*', recursive=True):
        print(filename)

        file = open(filename,'rb')                      # file to send

        session.storbinary('STOR '+filename, file)     # send the file
        time.sleep(5)
        file.close()                                    # close file and FTP
        session.quit()
except Exception as e:
    print( "Exception raised", str(e))
    session.quit()

我确实尝试过手动将文件拖放到此站点,但成功。 谁能帮我 谢谢 先生

0 个答案:

没有答案