Python爬虫常见一分彩系统制作报错及解决办法


一分彩系统制作q<115.28.8.00.9.9>报错:AttributeError: 'NoneType' object has no attribute 'strip'

检查是否是单词拼写错误。
检查是否是str类型
检查返回结果是否有空值,使用strip()前可以先判断是否为空,如下:
name = li.xpath(".//div[@class='nlcd_name']/a/text()").get()
if name is not None:
name = name.strip()
报错:AttributeError: 'NoneType' object has no attribute 'group'
检查是否拼写错误。
检查是否是str类型。
判断是否有空值。
district = re.search(r".*\[(.+)\].*", district_text)
if district is not None:
district = district.group(1)
TypeError: can only concatenate str (not "NoneType") to str

说操作过程中因为有空值(NoneType)出现而报错。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM