请求在Python中解码

时间:2014-07-24 04:30:30

标签: 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

如何将其转换为韩语?

1 个答案:

答案 0 :(得分:1)

这是UTF-8。

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

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