http协议uri编码

import urllib.parse
import string
import requests

url = 'https://baidu.com/s?'

params = {
    'wd': "中文",
    'key': "baidu",
    'value': "name"
}

str_params = urllib.parse.urlencode(params)
parse_url = url + str_params

end_url = urllib.parse.quote(parse_url, string.printable) # https://baidu.com/s?wd=%E4%B8%AD%E6%96%87&key=baidu&value=name
response = requests.get(end_url)
print(response.content.decode())

你可能感兴趣的:(python)