提交 7b9ee43d 编写于 作者: Y yangjiahua

open file by with to avoid do not close the file if IOError

上级 8a0a68ca
...@@ -16,9 +16,8 @@ Train = False # 不解压训练集,仅解压测试集 ...@@ -16,9 +16,8 @@ Train = False # 不解压训练集,仅解压测试集
# 解压缩,返回解压后的字典 # 解压缩,返回解压后的字典
def unpickle(file): def unpickle(file):
fo = open(file, 'rb') with open(file, 'rb') as fo:
dict_ = pickle.load(fo, encoding='bytes') dict_ = pickle.load(fo, encoding='bytes')
fo.close()
return dict_ return dict_
def my_mkdir(my_dir): def my_mkdir(my_dir):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册