diff --git a/Article/PythonBasis/python18/1.md b/Article/PythonBasis/python18/1.md index af1d7b9a..d78e4fd7 100644 --- a/Article/PythonBasis/python18/1.md +++ b/Article/PythonBasis/python18/1.md @@ -96,9 +96,12 @@ print(data_path) ```python from pathlib import Path +import os -base = Path('/tmp') -data_path = base / 'demo' / 'sub' / 'foo.txt' +file_exist = os.path.isfile('foo.txt') +if file_exist: + base = Path('/tmp') + data_path = base / 'demo' / 'sub' / 'foo.txt' print(data_path) ```