Articles → PYTHON → Rename and delete a file in python

Rename and delete a file in python






Code of renaming the file




import os

os.rename("c:/temp/copy.py","c:/temp/mycopy.py")



Output


Picture showing the file named using python

Click to Enlarge


Delete the file




import os
os.remove("c:/temp/mycopy.py")



Posted By  -  Karan Gupta
 
Posted On  -  Friday, September 10, 2021

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250