您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在python中将搁置文件清空?

5b51 2022/1/14 8:22:40 python 字数 1031 阅读 566 来源 www.jb51.cc/python

我创建了一个搁置文件并插入了一个字典数据.现在我想清理搁置文件以重用为干净文件. 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 t

概述

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()

或者,您可以随时删除文件,并让搁置创建一个文件.

总结

以上是编程之家为你收集整理的如何在python中将搁置文件清空?全部内容,希望文章能够帮你解决如何在python中将搁置文件清空?所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶