天天看點

python 異常捕獲

<a href="http://blog.csdn.net/spch2008/article/details/9343207" target="_blank">http://blog.csdn.net/spch2008/article/details/9343207</a>

例子一

import errno

try:

    os.mkdir(dirname)

except OSError as exc:

    if exc.errno != errno.EEXIST:

        raise exc

    pass

2.例子二

<a href="http://s1.51cto.com/wyfs02/M02/88/92/wKiom1f79gfjZm19AAHLpxvIgrQ584.jpg" target="_blank"></a>