【发布时间】:2015-04-05 09:20:37
【问题描述】:
我想检查以下文件是否存在:
$ANALYSISDIRECTORY/data/AnalysisDerivative/configuration.txt
目前,我有一个小功能来确保文件存在:
def ensureFileExistence(fileName):
log.debug("ensure existence of file {fileName}".format(
fileName = fileName
))
if not os.path.isfile(fileName):
log.info("file {fileName} does not exist\n".format(
fileName = fileName
))
sys.exit()
我应该如何让这个函数更健壮,并且能够处理存储在环境变量中的路径和路径?
【问题讨论】:
标签: python bash path environment-variables system