import os
import shutil
if os.path.exists("demofile.txt"):
os.remove("demofile.txt") # one file at a time
os.rmdir("test_directory") # removes empty directory
shutil.rmtree("test_directory") # removes not empty directory and its content
import os
os.remove("ChangedFile.csv")
print("File Removed!")
import os
os.remove('file_path')
import os
os.remove("/tmp/<file_name>.txt")
import os
# os.remove("text.txt")
# print("File deleted")
for file in os.listdir("fileDirectory"):
os.remove("fileDirectory"+file)
print(file, "deleted")
#!/usr/bin/python
import os
myfile="/tmp/foo.txt"
## If file exists, delete it ##
if os.path.isfile(myfile):
os.remove(myfile)
else: ## Show an error ##
print("Error: %s file not found" % myfile)
Code Example |
---|
:: python selenium go back |
:: |
Python :: python get location of script |
:: python get utc time |
Python :: |
:: |
Python :: |
:: |
:: |
:: |
Python :: |
:: |
:: |
Python :: |
:: |
:: |
:: |
:: |
:: export image python |
:: |
:: |
Python :: |
:: |
:: |
:: |
Python :: Python function remove all whitespace from all character columns in dataframe |
:: python write to json with indent |
:: |
:: |
:: adding whitenoise to middleware in django |