Post

PythonPython

H
Harshel Mike

Posted on 1st May 2024|15 views

0
votes

Python Overwrite File

How can I move and overwrite a file in python?

Answers
P
Anusha V

Posted on 1st May 2024

Moving a fine into a dictionary where there is another file with the same file name is called overwriting a destination file with the brand new source file.

Like this:

src_file = "/mindmajix/run/src_folder/example.txt"

dst_path = "/mindmajix/run/dst_folder/example.txt"

shutil.move(src_file, dst_path)

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos