每当连接丢失时,我都会尝试在python中实现FTP重新连接。当连接丢失时,我将调用Connect()函数,如下所示。为了模拟断开连接,我调用了ftp.logout(),然后尝试下载一个抛出异常的文件,在异常处理程序中,我调用了Connect()函数。
ftp = FTP("hostname")
def Connect():
print('Calling Connect')
ftp.login("user","password")我遇到了下面的异常AttributeError("'NoneType‘对象没有’sendall‘属性“)
有谁能解释一下这个吗?
发布于 2013-07-09 22:24:07
我怀疑您可以通过重新初始化connect()函数中的ftp变量来解决这个问题:
def Connect():
ftp = FTP("hostname")
print('Calling Connect')
ftp.login("user","password")https://stackoverflow.com/questions/17550520
复制相似问题