Python move a file ️

Channel Avatar
Comment
X
Share
Python move a file ️
Python move a file ️
Python move replace file tutorial example explained

#python #move #replace #file

import os

source /”C:////Users////User////Desktop////source.txt/”
destination /”C:////Users////User////Desktop////destination.txt/”

try:
if os.path.exists(destination):
print(/”There is already a file there/”)
else:
os.replace(source,destination)
print(source/” was moved/”)
except FileNotFoundError:
print(source/” was not found/”)

Bro Code merch store: https://teespring.com/stores/bro-code-5

Take the opportunity to connect and share this video with your friends and family if you find it useful.

Keywords: python move files, python move file, move a file in python, move files in python, os.replace(), python

Read Also

Leave a Reply

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