2013-02-13 105 views
1

對於這行代碼在Python 2.7:類型錯誤: 'NoneType' 對象不是可調用

print performer[0] 
print performer[0].split(">")[1] 

我得到

<span itemprop="name performers">Lindsey Stirling Tickets</span> 

OK結果在這裏,但

Traceback (most recent call last): 
File "C:\Users\Administrator\Desktop\format.py", line 51, in <module> 
    print performer[0].split(">")[1] 
TypeError: 'NoneType' object is not callable 

文本源自美麗的湯,所以不知道它的類型是搞砸了。之前曾經使用過拆分,但從未有過這些問題。

+1

發表更多代碼。看起來'performer [0] .split'是'None',所以'performer [0]'可能不是一個正常的'str'ing。 – nneonneo 2013-02-13 05:20:29

回答

0

是的,沒有意識到名單(執行者)隻影響名單而不是單個項目。

迭代通過改變每一個固定它。物品仍然是:

<class 'bs4.element.Tag'> 
相關問題