Python 在JMESPath中检测匹配失败

Python 在JMESPath中检测匹配失败,python,jmespath,Python,Jmespath,使用,如何区分匹配表达式的,值是无“与匹配表达式失败”比较 jmespath.search函数在两种不同的情况下返回None: >>导入jmespath >>>foo={'bar':{'lorem':13,'ipsum':None} >>>报告(jmespath.search('bar.lorem',foo)) '13' >>>repr(jmespath.search('bar.ipsum',foo))#路径匹配,无值 “没有” >>>repr(jmespath.search('dolor',f

使用,如何区分匹配表达式的,值是
“与匹配表达式失败”比较

jmespath.search
函数在两种不同的情况下返回
None

>>导入jmespath
>>>foo={'bar':{'lorem':13,'ipsum':None}
>>>报告(jmespath.search('bar.lorem',foo))
'13'
>>>repr(jmespath.search('bar.ipsum',foo))#路径匹配,无值
“没有”
>>>repr(jmespath.search('dolor',foo))#路径不匹配
“没有”

在这两种不同的情况下,JMESPath搜索API似乎返回
None
。调用者如何知道它们之间的区别呢?

目前看来无法区分匹配失败和返回
无的成功

有一个问题,但目前的答案显然是“你不能用
jmespath
”来解决这个问题