これを見る別の方法。例外の詳細を確認してください。
In [49]: try:
...: open('file.DNE.txt')
...: except Exception as e:
...: print(dir(e))
...:
['__cause__', '__class__', '__context__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__suppress_context__', '__traceback__', 'args', 'characters_written', 'errno', 'filename', 'filename2', 'strerror', 'with_traceback']
「as e」構文を使用してアクセスする「もの」はたくさんあります。
このコードは、このインスタンスの詳細を示すことのみを目的としています。
except Exception, e:とexcept Exception as e:。この質問は違いが間にあるものを尋ねるexcept:とexcept Exception as e:。