diff options
Diffstat (limited to 'Doc/howto/urllib2.rst')
-rw-r--r-- | Doc/howto/urllib2.rst | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst index 058cf96..3ac8312 100644 --- a/Doc/howto/urllib2.rst +++ b/Doc/howto/urllib2.rst @@ -115,6 +115,7 @@ library. :: 'language' : 'Python' } data = urllib.parse.urlencode(values) + data = data.encode('utf-8') # data should be bytes req = urllib.request.Request(url, data) response = urllib.request.urlopen(req) the_page = response.read() @@ -179,7 +180,8 @@ Explorer [#]_. :: 'language' : 'Python' } headers = { 'User-Agent' : user_agent } - data = urllib.parse.urlencode(values) + data = urllib.parse.urlencode(values) + data = data.encode('utf-8') req = urllib.request.Request(url, data, headers) response = urllib.request.urlopen(req) the_page = response.read() |