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'))


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

09-26 22:13