This is a read-write properties tool
Project description
安装 pip install pr-properties
这是一个读写properties工具
from pr_properties import Properties
# 创建Properties对象
p = Properties()
# 读取字符
str_p = """# 读取字符=1
master.initialSize=4
master.minIdle=10=20=kk"""
p.loads(str_p)
# 修改
p['master.initialSize'] = 5
# 增加
p['master.cc'] = 5
# 输出对象的字符
print(p.dumps())
# 删除
del p['master.cc']
print(p.dumps())
# 读写properties文件
p = Properties()
p.read(path=r'./pool.properties')
print(p['master.initialSize']) # 4
# 支持get
print(p.get('master.initialSize'))
# 修改
p['master.initialSize'] = 5
# 写入,写入后会关闭文件;写入功能请慎重使用
p.write()
p.read(path=r'./pool.properties')
# 验证是否修改
print(p['master.initialSize']) # 5
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pr_properties-1.7.8.tar.gz
(16.0 kB
view hashes)
Built Distribution
Close
Hashes for pr_properties-1.7.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 176b05ef2009a9b34081395a5be9266d3ef7bb5e42cfe7a328061c8080daeabb |
|
MD5 | 2b3b4e68e9b5f44e396763e9fca529fc |
|
BLAKE2b-256 | 9837e050a76587c1af29fb0dc8345331f2ad9c1bb9d1c4053a063e9db9d553db |