python - Python中的请求解码

标签 python urldecode

import urllib.request
url = ""
http_header = {
        "User-Agent": "Mozilla/5.0(compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0) like Gecko",
        "Accept": "text/html, application/xhtml+xml, */*",
        "Accept-Language": "ko-KR",
        "Content-type": "application/x-www-form-urlencoded",
        "Host": ""
}
params = {
        'id': 'asdgasd',
        'call_flag': 'idPoolChk',
        'reg_type': 'NY'
}

data = urllib.parse.urlencode(params).encode()
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
the_page = response.read()
print(the_page)

当我运行这个程序时,我得到:

\xec\x95\x84\xec\x9d\xb4\xeb\x94\x94\xea\xb0\x80 \xec\xa4\x91\xeb\xb3\xb5\xeb\x90\xa9\xeb\x8b\x88\xeb\x8b\xa4

如何将其转换为韩语?

最佳答案

它是 UTF-8。

print(the_page.decode('utf-8'))

假设您的控制台能够处理这些字符。

关于python - Python中的请求解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24925161/

相关文章:

python - http.server : decoding POST request to JSON

python - 确定两个单词是否来自 Python 中的同一个词根

python - 无法对谷歌数据存储应用投影查询。错误 : No matching index found

python - numpy 获取行索引,其中某些列中的元素为零

python - 最大化两个整数列表之间的总和? (有限制)

asp.net-mvc-4 - ASP.NET Web Api和UrlDecode

python - 使用Python输出YAML : incorrect formatting without lists in input

windows - Windows 是否有任何内置实用程序来编码/解码 URL?

r - 使用超过 1% 编码的字符进行 URLdecode

iphone - 将 URL 解码为 JSON