python jsonpath 断言,or用法
def test_json_extractor(obj:dict,expr):
# the obj must be dict
get_value=jsonpath.jsonpath(obj,expr)
return get_value or None
def test_or_return():
"""优先级是not>and>or"""
d = {'a': 'aaa', 'b': None}
res= d.get('b', '') or 'bbb'
print(res)
return res # bbb
def simple_else(p1,p2):
"""
if p1 return p1 else return p2
a = None or 2
b= [] or 1
"""
v = p1 or p2
return v


浙公网安备 33010602011771号