首页 > 解决方案 > 是否可以更改外部库保存的文件的保存路径?

问题描述

我在 python 中使用了一个名为的库pyansys,其中我使用了一个名为save_as_vtk.

它是:文档

此方法为我生成一个文件并将其保存到我的工作目录中。我希望将该文件保存在其他地方...我不希望它移动,因为有时它是 20+ Gb 并且需要太长时间。

有人有想法吗?

谢谢!

标签: pythonfile-iooutput-directory

解决方案


我是pyansys包的维护者。

这在https://github.com/akaszynski/pyansys/issues/219中得到了回答

在这里重复:

看来 ResultFile.save_as_vtk 已经有一个文件名参数:

def save_as_vtk(self, filename, rsets=None, result_types=['ENS']):
    """Writes results to a vtk readable file.

    The file extension will select the type of writer to use.
    ``'.vtk'`` will use the legacy writer, while ``'.vtu'`` will
    select the VTK XML writer.

    Parameters
    ----------
    filename : str
        Filename of grid to be written.  The file extension will
        select the type of writer to use.  ``'.vtk'`` will use the
        legacy writer, while ``'.vtu'`` will select the VTK XML
        writer.

推荐阅读