美文网首页
python3 url解码

python3 url解码

作者: 戒灵 | 来源:发表于2019-05-07 10:10 被阅读0次

    有时候我们需要分析一个链接或者dict 但是编码如:‘%7B%22id%22%3A%22bed255d’ 我们就很烦
    所以以下就是整理看起来不舒服的字符

    from urllib import parse
    from urllib import request
    import json
    a='%7B%22id%22%3A%22bed255dcc2583ef7a0ea2b22013a61ea036cebad%22%2C%22version%22%3A5%2C%22imageUrl%22%3A%22https%3A%2F%2Fimages-na.ssl-image' \
      's-amazon.com%2Fimages%2FI%2F416RLuy0NCL._AA60_.jpg%22%2C%22internalDescription%22%3A%22%E7%A7%92%E6%9D%80-2019%2F04%2F30%201-14-45-650%22%2C%22item' \
      's%22%3A%5B%7B%22quantity%22%3A19%2C%22quantitySold%22%3A-1%2C%22quantityWaitlisted%22%3A-1%2C%22price%22%3A32.2%2C%22sku%22%3A%22W-ID0089DE-01%22%2C%22ima' \
      'geUrl%22%3A%22https%3A%2F%2Fimages-na.ssl-images-amazon.com%2Fimages%2FI%2F416RLuy0NCL._SCLZZZZZZZ__.jpg%22%2C%22ingressUrl%22%3A%22http%3A%2F%2Fwww.amazon.de' \
      '%2Fb%3Fie%3DUTF8%26node%3D872398%22%2C%22egressUrl%22%3A%22http%3A%2F%2Fwww.amazon.de%2Fdp%2FB07PWD93HC%22%2C%22currencyCode%22%3A%22EUR%22%2C%22asin%22%3A%22B07P' \
      'WD93HC%22%2C%22workgroup%22%3A%22gl_home_improvement%22%7D%5D%2C%22name%22%3A%22edit%22%7D'
    a= parse.unquote(a) #解码字符串
    
    a= json.loads(a)
    
    

    相关文章

      网友评论

          本文标题:python3 url解码

          本文链接:https://www.haomeiwen.com/subject/tgwsoqtx.html