将字典转成URL请求参数 from urllib . parse import urlencode params = { 'a' : 1 , 'b' : 2 } result = urlencode ( params ) print ( result ) 将URL请求参数转成字典 from urllib . parse import parse_qs , urlparse url = 'https://s
将字典转成URL请求参数
from urllib.parse import urlencodeparams = {'a': 1, 'b': 2}
result = urlencode(params)
print(result)
将URL请求参数转成字典
from urllib.parse import parse_qs, urlparseurl = 'https://so.***.net/so/search?spm=1000.2115.3001.4498&q=test&t=&u='
query = urlparse(url).query
params = parse_qs(query)
print(params)