检查文件,如果存在的话os.path.isfile返回true:
import os.path
filename = './file.txt'
os.path.isfile(filename)
检查目录:
import os
path = './dir'
os.path.exists(path)
检查文件,如果存在的话os.path.isfile返回true:
import os.path
filename = './file.txt'
os.path.isfile(filename)
检查目录:
import os
path = './dir'
os.path.exists(path)