Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to empty a text file in python

file = open("sample.txt","r+")
file.truncate(0)
file.close()
Comment

empty python file

def main():

    #code
    
    return

if __name__=='__main__':
    main()
Comment

PREVIOUS NEXT
Code Example
Python :: python loop x times 
Python :: how to create requirements.txt django 
Python :: create python file kali linux 
Python :: boto3 upload file to s3 
Python :: create a role with discord.py 
Python :: python random real 
Python :: pyqt loading screen 
Python :: discord.py send messages 
Python :: Creating a list with list comprehensions 
Python :: load and image and predict tensorflow 
Python :: python make a new window 
Python :: python async await 
Python :: memory used by python program 
Python :: python getting class name 
Python :: python apply function to dictionary values 
Python :: how to print to a file in python 
Python :: how to smooth a function in python 
Python :: how to disable resizing in tkinter 
Python :: how to use with open 
Python :: python reverse linked list 
Python :: multiple line input python 
Python :: python remove background 
Python :: python undefine variable 
Python :: python web parser 
Python :: get int64 column pandas 
Python :: how to pair up two lists in python 
Python :: Insert missing data in pandas 
Python :: python file handling 
Python :: How to get the value of an Entry widget in Tkinter? 
Python :: pd count how many item occurs in another column 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =