开发者

How do I convert a regex with pack and hex from Perl to Python?

I am a newcomer to Python and am converting a 开发者_如何学PythonPerl 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.


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.


value = value.decode('hex')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜