1、要知道项目根目录是什么:
project_name = "InterfaceTest_project"
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = curPath[:curPath.find(project_name+"/")+len(project_name+"/")]
2、拼接根目录和文件目录:
firedir='{}reports/mypies'.format(rootPath) #文件目录
搞定!