Python, urlencode attributes


/ Published in: Python
Save to your folder(s)

Hello,
I am just new to Python, I have failed to resolve this Windows (Python Idle). The doc's point to this format, but I continually get the following error:
urlencode missing attribute
Traceback (most recent call last):
File "C:\Documents and Settings\My Documents\Python-dir\TEST-P1.py", line 15, in
data = headers + urllib.urlencode(body)
AttributeError: 'module' object has no attribute 'urlencode'

Checked for modules with the same name and Cygwin does not generate this error.


Copy this code and paste it in your HTML
  1. #!/usr/bin/python
  2.  
  3. import urllib
  4.  
  5. url = 'https://xxx.xxx.com/yyyyyy/yyy'
  6.  
  7. headers = {'USERID:user\@ccc.com','PASSWORD:dfdfdf','parm1:nnnn','parm2:hhh'}
  8.  
  9.  
  10. body = {'eemail=gggg.hhh\@gmail.com,parm3=build\(0\)'}
  11.  
  12. data = headers + urllib.urlencode(body)
  13. request = urllib.Request(url, data)
  14. response = urllib.urlopen(req)
  15. the_page = response.read()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.