将该方法放在根目录下面,在其他类中直接import 该方法。
import os def getRootPath(): rootPath = os.path.dirname(os.path.abspath(__file__)) return rootPath
【python接口自动化】获取根目录
原文:https://www.cnblogs.com/zipon/p/9141487.html