EN
Python - copy file example
0 points
In this article, we would like to show you how to copy file in Python.
Quick solution:
xxxxxxxxxx
1
import shutil
2
3
shutil.copyfile(source_path, destination_path)
In this example, we use copyfile()
method from shutil
package to copy example.txt
file.
xxxxxxxxxx
1
import shutil
2
3
shutil.copyfile("C:\\some_path\example_directory\example.txt",
4
"C:\\some_path\example_directory\example_copy.txt")
Result:


Note:
If the file under
destination_path
already exist it will be replaced.