python的helper库怎么使用_ConfigHelper-可以使用它保存或调用Python中的首选项。-Donggun LEE...

Config None Example # Config None Example

print("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)

"""

"""

except Exception as e:

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 Example # Config Dictionaray Example

print("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 Example # Config File Example

print("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 Example # Config Class Example

print("Config Class Example")

cfg_class = Config(Test)

print(cfg_class)

"""

{

"age": 24,

"name": "Donggun LEE"

}

"""

Config Object Example # Config Object Example

print("Config Object Example")

cfg_obj = Config(Test())

print(cfg_class)

"""

{

"age": 24,

"name": "Donggun LEE"

}

"""

Copy from pypi.org

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值