uploading file using urllib2
问题 I'm new to python and I'm writing a code to upload a file using urllib2 but I can't make it work. Here's the code: class Get(object): handlers = list() def __init__(self,url): self.url = url self.request = urllib2.Request(url) self.request.add_header('User-Agent',"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13") def auth(self,username,password): pass_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() pass_mgr.add_password(None, self.url, username, password)