How to find out if string has already been URL encoded?

后端 未结 11 1035
死守一世寂寞
死守一世寂寞 2020-11-30 03:46

How could I check if string has already been encoded?

For example, if I encode TEST==, I get TEST%3D%3D. If I again encode last string, I

11条回答
  •  臣服心动
    2020-11-30 04:01

    In order to avoid encoding twice and generating a bug (as the OP is stating) we unquote and than quote again, in Python this will be:

    import urllib.parse
    urllib.parse.unquote(str)
    urllib.parse.quote(str)
    

提交回复
热议问题