DEV Community

saurabh belote
saurabh belote

Posted on

python program to copy file

from shutil import copyfile
copyfile("/root/a.txt", "/root/b.txt")
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
rocketmaker69 profile image
RocketMaker69

or:

fa = open("root/a.txt", "r").read()
fb = open("root/b.txt", "w")
fb.write(fa)

Collapse
 
s_belote_dev profile image
saurabh belote

Thanks for sharing

Collapse
 
rocketmaker69 profile image
RocketMaker69

you're welcome!