使用python的os.path模块检查文件是否存在:
1、Returns True if the path is a regular file:
os.path.isfile('file_path')
2、Returns True if the path is a file, directory, or a valid symlink:
os.path.exists('file_path')
3、Returns True if the path is a directory:
os.path.isdir('file_path')