Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import urllib2
  4.  
  5. city = u'Köln'
  6.  
  7.  
  8. def make_url(word):
  9. Word = unicode(word)
  10. print type(Word)
  11. url_Word = urllib2.quote(Word, "utf-8")
  12. print "ntype = %s n" %type(Word)
  13. print "url_word = %s n" %url_Word
  14.  
  15.  
  16. make_url(city)
  17.  
  18. <type 'unicode'>
  19.  
  20. type = <type 'unicode'>
  21.  
  22. url_word = K%F6ln
  23.  
  24. <type 'unicode'>
  25. C:Python27liburllib.py:1285: UnicodeWarning: Unicode equal comparison failed
  26. to convert both arguments to Unicode - interpreting them as being unequal
  27. return ''.join(map(quoter, s))
  28. Traceback (most recent call last):
  29. File "to_Ask_question.py", line 21, in <module>
  30. make_url(city)
  31. File "to_Ask_question.py", line 16, in make_url
  32. url_Word = urllib2.quote(Word, "utf-8")
  33. File "C:Python27liburllib.py", line 1285, in quote
  34. return ''.join(map(quoter, s))
  35. KeyError: u'xf6'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement