一分彩系統制作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)出現而報錯。
