【问题标题】:double url encoding for ascii charachtersascii 字符的双 url 编码
【发布时间】:2020-12-18 23:37:22
【问题描述】:

python 中使用的库是什么,或者通常如何完成字符的双 URL 编码, 例子 : URL 编码 > %61 的字符 'a' 双 URL 编码的字符 'a' > %2561

如何从 'a' 获得 %2561?

【问题讨论】:

    标签: python web-applications character-encoding


    【解决方案1】:

    取决于您的用例。如果您不需要强大的解决方案,您可以使用 urllib

    import urllib.parse as parser
    encoded_string = "%2561"
    decoded_string = parser.unquote(encoded_string) # this would be '%61'
    double_decoded_string = parser.unquote(decoded_string) # this would be 'a'
    

    您也可以删除 decoded_string 变量,而是像这样调用它

    double_encoded_string = parser.unquote(parser.unquote(encoded_string))

    您可以从那里开始循环解码,而它包含编码字符等。

    【讨论】:

      猜你喜欢
      • 2014-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-07
      • 2014-01-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多