문제

Can anybody help me translating this python 2 code to python 3 without using the 2to3 tool ?

import urllib2, cookielib
self.cj = cookielib.MozillaCookieJar(self.cookie_file)
self.opener = urllib2.build_opener(
            urllib2.HTTPRedirectHandler(),
            urllib2.HTTPHandler(debuglevel=0),
            urllib2.HTTPSHandler(debuglevel=0),
            urllib2.HTTPCookieProcessor(self.cj)
        )
도움이 되었습니까?

해결책

I got the answer myself via Python docs:

import http.cookiejar
import urllib.request
self.cj = http.cookiejar.MozillaCookieJar(self.cookie_file)
self.opener = urllib.request.build_opener(
            urllib.request.HTTPRedirectHandler(),
            urllib.request.HTTPHandler(debuglevel=0),
            urllib.request.HTTPSHandler(debuglevel=0),
            urllib.request.HTTPCookieProcessor(self.cj)
        )
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top