json_data = {'success': True, 'code': 0, 'message': None, 'body': {'items': [], 'pager': {'pageIndex': 49, 'pageSize': 12, 'total': 0, 'totalPage': 0, 'sorting': None, 'sortType': 0}}}
# False
serial_names = jsonpath.jsonpath(json_data, '$.body.items[*].productName')
# 型号
product_models = jsonpath.jsonpath(json_data, '$.body.items[*].manufacturerPartNumber')
for name,model in zip(serial_names, product_models):
print(name, model)
报错原因分析:
因为返回数据导致 jsonpath 提取失败,此时 serial_names & product_models 的值为False,继而导致 for 循环 in 左边报错
标签:product,TypeError,json,jsonpath,bool,names,serial,data,iterable From: https://www.cnblogs.com/czzz/p/17014773.html