有如下字query符串s = "data=Ap/8ime+SAJmU=&a=dfasfds+fsdsaf&c=fas1mk342412"
需要转成dict{'data': 'Ap/8ime+SAJmU=', 'a': 'dfasfds+fsdsaf', 'c': 'fas1mk342412'}
试过dict(urlparse.parse_qsl(s))
,然而'+'会转成空格。
然后试过split('&')
,再split('=')
,然而'data'
的value
中包含'='。汗啊-_-!!
求一个高效的方法。
That’s it
However, the plus sign should be converted into a space!
Just use parse_qsl
My level can only go so far
Two o’clock
As @hsfzxjy said,
+
This is to convert the blank spaceIf you want to convert it into a dictionary, just use
parse_qs
at the beginning. It will be converted directly into dict. There is no need to manually transfer the list to itQuestions I answered: Python-QA