Home  >  Q&A  >  body text

python - type function problem

import requests
res=requests.get('http://news.sina.com.cn/china/')
res.encoding="utf-8"
#print(res.text)
from bs4 import BeautifulSoup
soup=BeautifulSoup(res.text,'html.parser')
aa=soup.select('a')
for ii in aa:
    print type(ii)

错误信息:SyntaxError: invalid syntax
迷茫迷茫2705 days ago491

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-24 11:37:27

    What is the python version, 2.x or 3.x? If it is 3.x, change the code to:

    print(type(ii)).
    
    

    reply
    0
  • Cancelreply