【问题标题】:URL-encoding and -decoding a string in Python在 Python 中对字符串进行 URL 编码和解码
【发布时间】:2014-01-10 10:24:16
【问题描述】:

有没有办法在 Python 中对字符串进行 urlencode/urldecode?我想强调我想要一个字符串,而不是dict。我知道对dict 执行此操作的函数。我可以很容易地用它构造一个对字符串执行此操作的函数,但我宁愿不必构造自己的函数。 Python 是否内置了这个功能?

(对于 Python 2.7 和 3.3 的答案将不胜感激。)

【问题讨论】:

    标签: python urlencode


    【解决方案1】:

    参见urllib 模块(docs here),尤其是urllib.quoteurllib.unquote 函数。

    【讨论】:

      【解决方案2】:

      urllib.unquote 可以解决问题

      【讨论】:

        猜你喜欢
        • 2019-08-18
        • 2010-10-26
        • 1970-01-01
        • 2012-07-02
        • 1970-01-01
        • 2016-01-13
        • 1970-01-01
        • 2012-06-05
        • 2020-07-22
        相关资源
        最近更新 更多