EN
Python - copy file example
0
points
In this article, we would like to show you how to copy file in Python.
Quick solution:
import shutil
shutil.copyfile(source_path, destination_path)
Practical example
In this example, we use copyfile()
method from shutil
package to copy example.txt
file.
import shutil
shutil.copyfile("C:\\some_path\example_directory\example.txt",
"C:\\some_path\example_directory\example_copy.txt")
Result:
Note:
If the file under
destination_path
already exist it will be replaced.