开发者

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

开发者 https://www.devze.com 2023-01-02 06:45 出处:网络
I am a newcomer to Python and am converting a 开发者_如何学PythonPerl script.What is the Python equivalent to...

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

精彩评论

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