字面上看來是:列表分配索引超出範圍的意思,也就是越界了。
怎麼這樣呢
先曬一下代碼:
def getNewsList(Newsurl):
count=1
global TITLE
res=requests.get(Newsurl)
soup=BeautifulSoup(res.text,'html.parser')
artcle=soup.select('.listList ul li')
for each in artcle:
TITLE[count]=each.text
count=count+1
報錯:list assignment index out of range.
這個原因呢,是artcle裏邊還是一個數組,數組就不能直接.text了.
暫且沒有解決