Add exit_ok=True in open file when parent dir is exists

This commit is contained in:
xuzg 2017-12-01 22:43:46 +08:00
parent 99c9a3f837
commit 1c7f5ed830
1 changed files with 1 additions and 1 deletions

View File

@ -72,7 +72,7 @@ def open_file(path, mode='wb+', buffer_size=-1, ignore_errors=False):
f = None f = None
try: try:
if path and not os.path.isdir(path): if path and not os.path.isdir(path):
makedirs(os.path.dirname(path)) makedirs(os.path.dirname(path), exist_ok=True)
f = open(path, mode, buffer_size) f = open(path, mode, buffer_size)
except Exception: except Exception:
if not ignore_errors: if not ignore_errors: