How to decode a (doubly) 'url-encoded' string in python

前端 未结 2 544
轮回少年
轮回少年 2021-02-05 06:45

Tried decoding a url-encoded string in the following way

some_string = \'FireShot3%2B%25282%2529.png\'
import urllib
res = urllib.unquote(some_strin         


        
相关标签:
2条回答
  • 2021-02-05 07:36

    Your input is encoded double. Using Python 3:

    urllib.parse.unquote(urllib.parse.unquote(some_string))
    

    Output:

    'FireShot3+(2).png'
    

    now you have the + left.

    Edit:

    Using Python 2.7 it of course is:

    urllib.unquote(urllib.unquote('FireShot3%2B%25282%2529.png'))
    
    0 讨论(0)
  • 2021-02-05 07:42

    urllib.unquote_plus(urllib.unquote_plus(some_string)) FireShot3 (2).png

    0 讨论(0)
提交回复
热议问题