我尝试使用urllib从http://ustc.edu.cn获取数据。但是,当我尝试从recv
调用中分配返回时,程序会因此追溯而崩溃:
>>> urllib.urlopen('http://ustc.edu.cn')
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 351, in open_http
errcode, errmsg, headers = h.getreply()
File "/usr/lib/python2.7/httplib.py", line 1202, in getreply
response = self._conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1127, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
KeyboardInterrupt
有时,它也会返回&#34;连接重置由同行&#34;消息。