tags:

views:

53

answers:

2

I am a newcomer to Python and am converting a Perl script. What is the Python equivalent to...

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

Any help is greatly appreciated.

+1  A: 

You should likely just use urllib.unquote (python 2) / urllib.parse.unquote (python 3), since it looks like that's what the code you provided is trying to accomplish.

hobbs
Indeed, the code snippet appears here http://www.cgi101.com/class/ch4/text.html for example
gnibbler
A: 
value = value.decode('hex')
gnibbler