summaryrefslogtreecommitdiffstats
path: root/Doc/howto/urllib2.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/howto/urllib2.rst')
-rw-r--r--Doc/howto/urllib2.rst4
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
index 76286bd..567c1b1 100644
--- a/Doc/howto/urllib2.rst
+++ b/Doc/howto/urllib2.rst
@@ -108,6 +108,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()
@@ -172,7 +173,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()