0

For example, I want to convert

'http://en.wikipedia.org/wiki/Ana%C3%AFs_Croze'

to

u'http://en.wikipedia.org/wiki/Anaïs_Croze'

How to do this in Python?

chenaren
  • 2,090
  • 1
  • 19
  • 24

1 Answers1

4
>>> import urllib2
>>> print urllib2.unquote('http://en.wikipedia.org/wiki/Ana%C3%AFs_Croze')
http://en.wikipedia.org/wiki/Anaïs_Croze
>>> 

The above code as a runnable 'bunk' http://codebunk.com/bunk#-Iy8_GcBQ02jlMauuYP4

warvariuc
  • 57,116
  • 41
  • 173
  • 227
spicavigo
  • 4,116
  • 22
  • 28
  • Is this locale dependent ? I get `http://en.wikipedia.org/wiki/Anaïs_Croze` – Emmanuel Jun 28 '13 at 07:25
  • @Emmanuel : Your file (or shell) must be unicode encoded. For files use as first line something like `# encoding: utf-8` and make sure that your editor saves it as unicode. – mawimawi Jun 28 '13 at 08:10