[Python]获得当前文件的目录
2018-12-08 本文已影响1人
VanJordan
resultFilePath = os.path.split(os.path.realpath(__file__))[0] + '/' + model_name + "_weights/" + dataset_name + "/" + "result" + ".txt"
print(resultFilePath)
if not os.path.exists(resultFilePath):
# with open(resultFilePath,'w'):
# pass
os.mknod(resultFilePath)
获取上一级目录
resultFilePath = os.path.dirname(os.path.split(os.path.realpath(__file__))[0]) + '/' + model_name + "_weights/" + dataset_name + "/" + "result" + ".txt"
print(resultFilePath)
if not os.path.exists(resultFilePath):
# with open(resultFilePath,'w'):
# pass
os.mknod(resultFilePath)