繁体   English   中英

使用klepto.archives.file_archive时如何更改文件中的字典名称?

[英]How to change the name of dictionary in the file when using klepto.archives.file_archive?

运行以下代码后,我发现文件memo.py中的字典名称是memo 我想更改该文件中字典的名称。 有谁知道怎么做?

>>> init = {'y': 2, 'x': 1, 'z': 3}
>>> import klepto
>>> cache = klepto.archives.file_archive('memo', init, serialized=False)
>>> cache        
{'y': 2, 'x': 1, 'z': 3}
>>>
>>> # dump dictionary to the file 'memo.py'
>>> cache.dump() 
>>> 
>>> # import from 'memo.py'
>>> from memo import memo
>>> print memo
{'y': 2, 'x': 1, 'z': 3}
>>> from memo import memo
>>> print memo
{'y': 2, 'x': 1, 'z': 3}

我是klepto作者。 目前我不相信这是可能的。 但是,如果你确实想要它作为一个功能,那么随意请求(在klepto的GitHub上)作为增强功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM