← How-To Guides How-To How to copy a file Use shutil.copy(src, dst) or shutil.copy2 to preserve metadata. shutil.copy copy copies content; copy2 also copies timestamps. import shutil shutil.copy('a.txt', 'b.txt')