美文网首页
[Python]获得当前文件的目录

[Python]获得当前文件的目录

作者: VanJordan | 来源:发表于2018-12-08 23:33 被阅读1次
    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)
    
    

    相关文章

      网友评论

          本文标题:[Python]获得当前文件的目录

          本文链接:https://www.haomeiwen.com/subject/phochqtx.html