shutil.copyfile()

shutil.copyfile(src, dst, *, follow_symlinks=True)

Copy the contents (no metadata) of the file named src to a file named dst and return dst. src and dst are path names given as strings. dst must be the complete target file name; look at shutil.copy() for a copy that accepts a target directory path. If src and dst specify the same file, SameFileError is raised.

The destination location must be writable; otherwise, an OSError exception will be raised. If dst already exists, it will be replaced. Special files such as character or block devices and pipes cannot be copied with this function.

If follow_symlinks is false and src is a symbolic link, a new symbolic link will be created instead of copying the file src points to.

Changed in version 3.3: IOError used to be raised instead of OSError. Added follow_symlinks argument. Now returns dst.

Changed in version 3.4: Raise SameFileError instead of Error. Since the former is a subclass of the latter, this change is backward compatible.

doc_python
2016-10-07 17:41:54
Comments
Leave a Comment

Please login to continue.