轻松遍历和查询字典
项目描述
轻松遍历和查询字典
免费软件:BSD许可证
安装
pip install t_dict
为什么?
处理深度嵌套的字典可能非常痛苦。TDict旨在通过使用jsonpointer语法使其变得不那么无聊。
它依赖于jsonpointer(《https://pypi.python.org/pypi/jsonpointer》),该库实现了RFC - 《https://tools.ietf.org/html/rfc6901》
用法
from t_dict.t_dict import TDict
td = TDict({'nested': { 'dict': 'here', 'other': {'spam': 'eggs'} }})
td.find('/nested/dict')
>> 'here'
td.find('/nested/notfound', 'defaultvalue')
>> 'defaultvalue'
td.setin('/nested/dict', 'new')
td['nested']['dict'] == 'new'
>> True
# converts dict to TDict
isinstance(td.find('/nested/other'), TDict)
>> True
历史
0.1.0 (2014-01-11)
PyPI上的首次发布。