Skip to content

Python code snippet – How to clear a pickle file?

#Create an empty variable
empty_list = []
#Open the pickle file in 'wb' so that you can write and dump the empty variable
openfile = open('filename', 'wb')
pickle.dump(empty_list, openfile)

See also  How to sort list in ascending order in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.