才學python爬蟲(python3.4),如何輸出裡面的"女間諜"呢?求教
htmll ='''<a class="nbg" href="http://movie.douban.com/subject/25752261/" title="女間諜">
<img alt="女間諜" class="" src="http://img4.douban.com/view/movie_poster_cover/ipst/public/p2254455238.jpg"/>
</a>'''
from bs4 import BeautifulSoup
soup = BeautifulSoup(htmll)
print(soup.a.img.get_text()) #輸出結果為空
img是個非封閉標簽,哪裡有text?改成 soup.a.img['alt']才行, 還有html1的賦值, 應該是三引號吧,復制代碼時不要弄錯了