parse query string with urllib in Python 2.4

后端 未结 3 493
轻奢々
轻奢々 2021-02-05 21:16

Using Python2.4.5 (don\'t ask!) I want to parse a query string and get a dict in return. Do I have to do it \"manually\" like follows?

>>> qs = \'first=         


        
3条回答
  •  余生分开走
    2021-02-05 21:57

    import urlparse
    qs = 'first=1&second=4&third=3&first=0'
    
    print dict(urlparse.parse_qsl(qs))
    
    OR
    
    print urlparse.parse_qs(qs)
    

提交回复
热议问题