#.实际会找项目根目录绝对路径即 os.getcwd() # 当前文件的绝对路径 current_work_dir =os.path.dirname(__file__) # 同级文件名为返回值 os.path.join(current_work_dir, "文件名.txt")