1、获取当前路径 parent = os.path.dirname(os.path.realpath("__file__")) 2、获取上一级路径 garder = os.path.dirname(parent)