我只输入了一些代码:
import urllib
response=urlib.urlopen(“www.baidu.com”)
然后是错误代码:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 469, in open_file
return self.open_local_file(url)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 483, in open_local_file
raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] No such file or directory: ‘www.baidu.com’
答案 0 :(得分:0)
您需要在"http://"
的前面放置"https://"
或URL
,因此请尝试:
import urllib
response=urlib.urlopen('http://www.baidu.com')
或者:
import urllib
response=urlib.urlopen('https://www.baidu.com')
注意:请使用'
或"
代替”
和“
。