可以使用它来保存或回忆Python中的首选项。

ConfigHelper的Python项目详细描述


配置帮助程序

可以使用它从python中保存或调用首选项。

  • 版权所有(c)2019 InfoLabDonggun LEE

  • 如何安装

    pip install ConfigHelper
    
    • 其他版本
      # 0.0.3
      pip install ConfigHelper==0.0.3
      
  • 功能

    config=ConfigHelper(data:dict)config=ConfigHelper(path:str)# URL is not supported.config=ConfigHelper(cls:type)# Classconfig=ConfigHelper(obj)# is not None# Returns the value.defgetValue(key:str):returnValue# Modify or add new value. defsetValue(key:str,value:object):returnNone# Create New Object. (Init Variable)defnewObject(cls:Class):returnObject# Put a value in ObjectdefsetObject(obj:Object):pass# Return as "Dictionary".deftoDict():returnDictionary# Return as "JSON".deftoJSON():returnString(=JSON)# Return as "File".deftoFile(path:string):returnfile
  • 如何使用

    • 测试类
      # Test ClassclassTest:def__init__(self):self.name="Donggun LEE"self.age=24def__str__(self):return"name : {}, age : {}".format(self.name,self.age)
    • 导入confighelper
      fromConfigHelperimportConfig
    • 无配置示例
      # Config None Exampleprint("Config None Example")cfg_none=Config()cfg_none.setValue("Version","0.0.1")cfg_none.setValue("isTemporary",0)cfg_none.setValue("isUserMode",1)print(cfg_none.isTemporary)"""    0"""print(cfg_none.Version)"""    0.0.1"""print(cfg_none.toJSON())"""    {        "Version": "0.0.1",        "isTemporary": 0,        "isUserMode": 1    }"""test=Test()print(test)"""    name : Donggun LEE, age : 24"""cfg_none.setValue("name","LEE Donggun")cfg_none.setObject(test)print(test)"""    name : LEE Donggun, age : 24"""try:print(test.Version)"""    """exceptExceptionase:print(e)"""        'Test' object has no attribute 'Version'    """print(cfg_none.Version)"""    0.0.1"""print(cfg_none.toDict()['Version'])"""    0.0.1"""cfg_none.toFile("d:/a/b/c/d/e/f/config.json")
    • 配置字典示例
      # Config Dictionaray Exampleprint("Config Dictionaray Example")cfg_dict=Config({"name":"LEE Donggun","age":40})print(cfg_dict)"""    {        "age": 40,        "name": "LEE Donggun"    }"""test=cfg_dict.newObject(Test)print(test)"""    name : LEE Donggun, age : 40"""cfg_dict.setValue("age",70)cfg_dict.setObject(test)print(test)"""    name : LEE Donggun, age : 70"""
    • 配置文件示例
      # Config File Exampleprint("Config File Example")cfg_file=Config("d:/a/b/c/d/e/f/config.json")print(cfg_file)"""{        "Version": "0.0.1",        "isTemporary": 0,        "isUserMode": 1,        "name": "LEE Donggun"}"""
    • 配置类示例
      # Config Class Exampleprint("Config Class Example")cfg_class=Config(Test)print(cfg_class)"""    {        "age": 24,        "name": "Donggun LEE"    }"""
    • 配置对象示例
      # Config Object Exampleprint("Config Object Example")cfg_obj=Config(Test())print(cfg_class)"""    {        "age": 24,        "name": "Donggun LEE"    }"""

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

推荐PyPI第三方库


热门话题
ws-consumer服务地址中的java动态属性   java如何比较整数列表,然后按升序排序?   javascript我正在使用java脚本调用一个函数,但它没有调用代码下面的方法,也没有调用secretitnames()函数   在文本窗格中多次使用Java insertIcon图标   JavaMSAL安卓。AuthenticationActivity完成,但用于身份验证请求的线程池线程仍处于等待状态   if语句中的java多范围比较   java toString()表示输出   java如何在jcstrest测试中生成指令重新排序   java我怎样才能运行它?   web应用程序中使用Hibernate和Spring的java问题   如何将字符串数据写入Java文本文件   如何在java命令提示符下运行已签名的jar文件?   java从我的菜单调用RCP应用程序   java如何等待Canvas/GraphicsContext完成任务,然后再继续执行代码块?