运行以下代码后,我发现文件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}发布于 2019-06-07 13:07:02
我是klepto的作者。目前,我不认为这是可能的。但是,如果您确实想要它作为一个功能,那么请随时请求它作为增强功能(在klepto的GitHub上)。
https://stackoverflow.com/questions/56474418
复制相似问题