首页 > 其他分享 >TypeError: ‘bool’ object is not iterable

TypeError: ‘bool’ object is not iterable

时间:2022-12-30 14:24:36浏览次数:41  
标签:product TypeError json jsonpath bool names serial data iterable

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

相关文章

  • Java千问10:你知道Java语言boolean类型的变量到底占多大空间吗?
    ​我们都知道,Java语言中有个boolean类型。每个boolean类型的变量中存储的是一个true或者是false的逻辑值。那么存储这个逻辑值,需要多大的空间呢?从理论上来讲,存储这个逻辑值......
  • _Bool類型
    _Bool類型:布爾變量,其值只有1(真)和0(假)。是C語言中的變量名,C語言中所有的非0數字都被視爲真。給布爾變量取一個能表示真或假值的變量名是一種常見的做法。1/*boolean.c--......
  • 【Python】爬虫笔记-TypeError: Object of type 'method' is not JSON serializable
    最近尝试对b站做数据分析,自己边学边造轮子。b站的api返回的格式都是json,在对数据进行格式转换的过程中遇到一个令人哭笑不得的问题,特此记录下来。0x01首先获得b站的api......
  • IfcBooleanChoose
    IfcBooleanChoose功能定义如果为TRUE,则返回第一个选项,否则返回第二个选项。 注:根据ISO/IEC10303-42:1992的定义此函数根据布尔输入参数的值返回两个选项之一。这两......
  • TypeError: Assignment to constant variable
    场景: 使用跨组件通信时,想通过重置父组件的值时,浏览器报错TypeError:AssignmenttoconstantvariableES6标准引入了新的关键字const来定义常量,const与let都具有块......
  • Uncaught (in promise) TypeError: Cannot set property 'value' of undefined解决办
    报错在vue中想给computed属性赋值的时候发生的报错原因computed计算属性不能使用箭头函数设置getter或setter解决办法computed:{ propertyName:{ get:()=>{ ......
  • TypeError: forEach is not a function in JavaScript
     以下代码: constparent=this.el.parentElementconsole.log(parent.children)parent.children.forEach(child=>{console.log(child)}) 运行后出现以下错......
  • VUE使用axios数据请求时报错 TypeError Cannot set property 'xxxx' of undefined 的
    正常情况下在data里面都有做了定义data(){list:"haha"}在函数里面进行赋值this.list=response.data.result这时候你运行时会发现,数据可以请求到,但是会报错TypeErr......
  • 'bool' object is not callable
    报错:'bool'objectisnotcallable原因:is_authenticated是属性而不是方法解决:把括号去掉就可以了demo:classA():def__init__(self,x):self.x=x......
  • ES搜索- term与match区别&bool查询
    term属于精确匹配,只能查单个词,tems可以匹配多个词(满足其中之一词的都会被搜索出来),多个词如果要同时匹配使用bool的must(must中带多个term);match进行搜索的时候,会先进行分......