一分彩系统制作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)出现而报错。