python copy file code example

Example 1: python copy file

from shutil import copyfile
copyfile(src, dst)

Example 2: python copy file to new filename

shutil has many methods you can use. One of which is:

from shutil import copyfile
copyfile(src, dst)

Example 3: copy file in python3

import shutil

original = r'original path where the file is currently stored\file name.file extension'
target = r'target path where the file will be copied\file name.file extension'

shutil.copyfile(original, target)

Example 4: copyfile pyhon

from shutil import copyfile
copyfile(src, dst)