允许持久存储字典数据

scribble的Python项目详细描述


概述

scibble是一种将字典信息存储到持久性 国家。这样可以方便地检索和编辑数据,使其 尝试存储设置数据时的一个好选择。

注意:ScribbleDictionary中保存的数据必须是可序列化的JSON。

创建持久数据块的示例如下:

importosimportscribble# -- Instance a scribble dictionary. We can treat this exactly# -- as we treat a dictionarydata=scribble.get('foobar')# -- Set some key/value pairs in the ScribbleDictionarydata['option_a']=Truedata['option_b']=123# -- Calling .save() will trigger the dictionary# -- to store its current state to a persistent statedata.save()# -- We can see the location the data is saved to, and we can# -- see that it does indeed existprint(data.location())print(os.path.exists(data.location()))

同样,我们可以在一个全新的python实例中重新检索数据 使用以下代码:

# -- Instance a scribble dictionary with the same identifierdata=scribble.get('foobar')# -- Print the fact that we have retrieved the same # -- infromationprint(data)# {'option_a': True, 'option_b': 123}# -- We can then further edit the datadata['option_a']=False# -- Calling .save() will trigger the dictionary# -- to store its current state to a persistent statedata.save()

默认情况下,scribble会将其数据存储在以下特定平台中 位置:

  • 窗口:appdata%/pyscribble

  • Linux:如果存在环境变量,则%xdggObjultGoe%/PyScript,否则%%HOM//CONFIG/PyScript B/<

  • OSX:_home/documents/pyscribble

但是,可以通过设置环境变量来覆盖这些路径 pyscribble_storage_dir,如果设置了此项,则该变量定义的路径 将始终用于默认行为。

相容性

这已经在ubuntu和windows上的python 2.7.13和python 3.6.6下进行了测试。

贡献

如果你想贡献思想,想法,修复或功能请联系!mike@twisted.space

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
算法图形。路径方向Java枚举方向问题无法使用EAST   Java:将字符串转换为特定语言环境   javaspringboot&Thymeleaf为后续调用保存搜索表单的最佳方法   mapreduce程序中未调用java reducer   java如何将url中的Gif文件保存到手机中?   如何在JavaSwing中使用[Esc]键最小化JInternalFrame?   java创建了一个包含100个按钮、80个空按钮和20个随机按钮的网格布局   如何在java中使用数组对2d字符串数组中的每一行进行排序。分类   java无法识别的SSL消息,纯文本连接?例外   为什么Java编译器允许在抛出部分列出方法无法抛出的异常   java将预测数组添加到训练数组   java从Ajax调用获取响应文本   使用改型2的java应用程序等待一分钟后退出