处理json和pickle文件的文件管理器
jpfmanager的Python项目详细描述
您可以使用jpf管理器帮助使用json或pickle在文件中保存/获取对象
示例:
文件test_jpf.py
:
from pathlib import Path
from jpfmanager.jpf import FileManager
from toti_class import toti
if __name__ == "__main__":
x = toti(5,6)
pathi = str((Path(__file__).parent / 'test1.tst').absolute())
FileManager.save(x,pathi)
newX = FileManager.get(pathi)
print(newX)
文件toti_class.py
在文件管理器.save(对象,路径,方法=无)
Args:
path: provide a string path to where the file will be saved
object: provide the object you want to save in that file
method: save using either json or pickle, json is set by default
Returns:
bool representing if the save operation succedded
在文件管理器.get(路径,方法=无):
Args:
path: provide a string path to where the file is saved
method: save using either json or pickle, json is set by default
Returns:
False if the path is not correct or it is not a file path
the content txt file in case of using json method and object in case of using the pickle method
- 项目
标签: