Best Practice to Python Copy and Move File – Python Shutil Tutorial

By | August 7, 2019

Copying and moving file are common operations in python, in this tutorial, we will introduce you an easy way to copy and move file with shutil library. shutil allow you copy and move files directly, you do not need open and close file before copying or moving.

python file operation tutorials and examples

Copy file

import shutil
shutil.copy(src, dst)

if this function is successful to copy, return dst.

Move file

import shutil
shutil.move(src, dst)

Return dst if successful.

So if you want to copy or move a file, you only shoud provide a source file path and destination path.

Leave a Reply

Your email address will not be published. Required fields are marked *