处理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

^{pr2}$

在文件管理器.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

json pickle file manager repo

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

推荐PyPI第三方库


热门话题
java InputStream对象在声明后关闭   java未定义名为“transactionManager”的bean重命名transactionManager   java“jar”命令何时会拒绝将类添加到java中。jar文件?   java JPA标准依赖WHERE子句   安卓中从SD卡读取文本文件时出现java错误   java直接启用类似位置的权限   使用@WebMvcTest和Mockito-BDDMockito对SpringBoot-RestController进行java测试   java JSESSIONID存储在哪里?   java jtextarea鼠标事件覆盖容器鼠标事件   java DRL无法解析动态加载的类   java是从一个方法返回多个对象的最简单方法   java自定义按钮/编辑框是否不可见?   java GUI如何在保存用户输入的同时在面板或框架之间切换   swing Java自定义JSlider不会更新   GridBagLayout中的java超过1个JPanel   java从ProjectReactor中的flux中采样除第一个元素外的所有元素   Java泛型和泛型类型   Java代码生成宽指令的jvm