Ubuntu 如何通过使用urllib接收数据来解决此崩溃?

Ubuntu 如何通过使用urllib接收数据来解决此崩溃?,ubuntu,urllib,Ubuntu,Urllib,我正在尝试使用urllib从中获取数据。但是,当我尝试分配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 urlop

我正在尝试使用urllib从中获取数据。但是,当我尝试分配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

偶尔,它也会通过对等消息返回连接重置。

欢迎使用堆栈溢出!我对你的问题做了一些修改,使它更清楚一些。然而,为了让我们真正帮助您,我们需要知道更多的细节——您应该发布您正在使用的代码,以及堆栈跟踪。一般来说,越详细越好。看起来您在获取过程中按了Ctrl+C组合键,从而中断了操作。