I assume that you open them with a function urlopen(). Its documentation states:
This function returns a file-like object with two additional methods:
- , close, :
connection = urllib2.urlopen(url)
connection.close()
: , :
>>> import urllib2
>>> import cookielib
>>> cj = cookielib.CookieJar()
>>> opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
>>> r = opener.open("http://www.python.org")
>>> html = r.read()
>>> r.close??
Type: instancemethod
Base Class: <type 'instancemethod'>
String Form: <bound method addinfourl.close of <addinfourl at 150857644 whose fp = <socket._fileobject object at 0x8fd48ec>>>
Namespace: Interactive
File: /usr/lib/python2.6/urllib.py
Definition: r.close(self)
Source:
def close(self):
self.read = None
self.readline = None
self.readlines = None
self.fileno = None
if self.fp: self.fp.close()
self.fp = None
, close() - :
>>> r.close()
>>> r.read()
------------------------------------------------------------
Traceback (most recent call last):
File "<ipython console>", line 1, in <module>
TypeError: 'NoneType' object is not callable