用简单的方法遍历和查询dicts
t_dict的Python项目详细描述
以简单的方式遍历和查询dict
- 免费软件:BSD许可证
安装
pip install t_dict
为什么?
处理深度嵌套的dict可能是一件非常痛苦的事情。tdict的目标是使用jsonpointer语法来减少使用它的无聊。
它站在jsonpointer(https://pypi.python.org/pypi/jsonpointer)的肩膀上,后者实现了rfc-https://tools.ietf.org/html/rfc6901
使用量
fromt_dict.t_dictimportTDicttd=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 TDictisinstance(td.find('/nested/other'),TDict)>>True
历史
0.1.0(2014-01-11)
- pypi上的第一个版本。