【发布时间】:2013-09-20 21:01:27
【问题描述】:
我试图在 Python 2.7 中捕获这个特定的异常(并且只有这个异常),但我似乎找不到关于异常类的文档。有吗?
[Errno 10054] An existing connection was forcibly closed by the remote host
到目前为止我的代码:
try:
# Deleting filename
self.ftp.delete(filename)
return True
except (error_reply, error_perm, error_temp):
return False
except # ?? What goes here for Errno 10054 ??
reconnect()
retry_action()
【问题讨论】:
-
最有可能的是,无论抛出什么,都源自内置的
Exception(如果写此内容的人遵循docs),因此您可以捕获它并检查它的类型。
标签: python sockets exception python-2.7