import shelve dict = shelve.open("Sample.db") # insert some data into sample.db dict = { "foo" : "bar"} #Now I want to clean entire shelve file to re-insert the data from begining.
dict.clear()
或者,您可以随时删除该文件,并让搁置创建一个新文件.