Hey guys, in this blog we will see a Python Program to Copy a File.
Using shutil module
from shutil import copyfile copyfile("/root/a.txt", "/root/b.txt")
Method | Preserves Permissions | Supports Directory as Destination | Copies Metadata | Supports file object |
---|---|---|---|---|
copy() | Yes | Yes | No | No |
copyfile() | No | No | No | No |
copy2() | Yes | Yes | Yes | No |
copyfileobj() | No | No | No | Yes |
- Here we have used the copyfile() method from shutil python package.
- It takes 2 arguments; source file path and destination file path.
Check out our other python programming examples…