mmengine.fileio.copyfile¶
- mmengine.fileio.copyfile(src, dst, backend_args=None)[源代码]¶
Copy a file src to dst and return the destination file.
src and dst should have the same prefix. If dst specifies a directory, the file will be copied into dst using the base filename from src. If dst specifies a file that already exists, it will be replaced.
- 参数:
- 返回:
The destination file.
- 返回类型:
- 抛出:
SameFileError – If src and dst are the same file, a SameFileError will be raised.
示例
>>> # dst is a file >>> src = '/path/of/file' >>> dst = '/path1/of/file1' >>> # src will be copied to '/path1/of/file1' >>> copyfile(src, dst) '/path1/of/file1'
>>> # dst is a directory >>> dst = '/path1/of/dir' >>> # src will be copied to '/path1/of/dir/file' >>> copyfile(src, dst) '/path1/of/dir/file'