![](/img/trans.png)
[英]How to set a table name using klepto sqltable_archive in Python 3?
[英]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.