Articles → PYTHON → Rename And Delete A File In PythonRename And Delete A File In PythonIn this article, we will rename a file in Python.Code Of Renaming The File To rename the file, we will use the following code: -import os os.rename("c:/temp/copy.py","c:/temp/mycopy.py")Output Delete The File We can delete the file using the following code: -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/Feedback Characters remaining 250**
import os os.rename("c:/temp/copy.py","c:/temp/mycopy.py")
import os os.remove("c:/temp/mycopy.py")
Query/Feedback