urllib2报错,用urllib.request来代替 正确代码: import urllib.request response=urllib.request.urlopen("http://python.org/") html=response.read() #print(len(html)) tokens=[tok for tok in html.split()] print(tokens[0:100]) 注意这里网址一定要用双引号!!! 最后运行正确: