晕,假设你的文件名是filenameos.path.abspath(filename)得到的就是文件名的绝对地址如果你相得到绝对目录可以这样子os.path.abspath(os.path.dirname(filename))