Leo*_*ban 1 python syntax terminal
遵循关于Tuts +的Python教程,我在下面的代码中遇到语法错误:
#!/usr/bin/env python
from bs4 import BeautifulSoup
from urllib import urlopen
html = urlopen('http://www.brainyquote.com/quotes/topics/topic_life.html').read()
soup = BeautifulSoup(html)
for section in soup.findAll('span',{"class":"bqQuoteLink"})
print section
break
Run Code Online (Sandbox Code Playgroud)

该教程要求我下载并安装BeautifulSoup,我没有错误.我唯一能想到的是我使用4.3而教程作者使用4.1?
试试这个:
for section in soup.findAll('span', {"class":"bqQuoteLink"}):
Run Code Online (Sandbox Code Playgroud)
......你:在循环结束时忘记了.