Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python delete text in text file

# Delete all text in a text file
f = open("text_file.txt", "r+")
f.truncate(0)
f.close()
Comment

deleting a file in python

import os
os.remove('file_path')
Comment

Deleting a file using python

import os

# os.remove("text.txt")
# print("File deleted")


for file in os.listdir("fileDirectory"):
    os.remove("fileDirectory"+file)
    print(file, "deleted")
Comment

PREVIOUS NEXT
Code Example
Python :: python count character occurrences 
Python :: how to alight and place ipywidgets 
Python :: Fill data in dataframe in pandas for loop 
Python :: python logging basicConfig+time 
Python :: how to merge between two columns and make a new one in pandas dataframe 
Python :: delete column in dataframe pandas 
Python :: read .mat file in python 
Python :: clone keras model 
Python :: Print First 10 natural numbers using while loop 
Python :: pandas concat 
Python :: termcolor print python 
Python :: dfs in python 
Python :: resample ohlc pandas 
Python :: python scope 
Python :: Setting Up Stylesheet Django 
Python :: xpath start-with python 
Python :: python get local ipv4 
Python :: update_or_create django 
Python :: python asyncio gather 
Python :: mypy clear cache 
Python :: pandas fillna with another column 
Python :: python timeout exception 
Python :: drop portion of string in dataframe python 
Python :: make widget span window width tkinter 
Python :: pandas dataframe first rows 
Python :: os path splitext 
Python :: python serial readline 
Python :: neural network hyperparameter tuning 
Python :: seaborn barplot remove error bars 
Python :: qpushbutton pyqt5 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =