Skip to content

Instantly share code, notes, and snippets.

@lhsfcboy
Last active August 4, 2017 04:06
Show Gist options
  • Save lhsfcboy/6d17397d39c33c498abbeb57ecb60d3e to your computer and use it in GitHub Desktop.
Save lhsfcboy/6d17397d39c33c498abbeb57ecb60d3e to your computer and use it in GitHub Desktop.
try_catch示例
for filepath in filelist: # filelist中是文件路径的列表
try:
with open(filepath, 'r') as f:
# 执行数据处理的相关工作
pass
print('{} is processed!'.format(filepath))
except IOError:
print('{} with IOError!'.format(filepath))
# 异常的相应处理
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment