python 中如何对抛出的异常进行进一步的处理。
我现在实现的是一个ftp下载的功能,但是对端的FTP服务器不稳定,经常的终断
,我想实现的功能是,当ftp终断的时候,重新再进行ftp连接。(这个是我目前想实现的功能)
例如:
file_handler = open(localdir+filename,'wb').write
try:
ftp.retrbinary('RETR %s' %(remotefile+filename),file_handler,bufsize)
except Exception as e:
print e ===现在已经知道打印出来e的值是[Errno 32] Broken pipe,
if e =='[Errno 32] Broken pipe':
ftp.connect('IP','21')
ftp.login('user','pwd')