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