는 내가 httplib.request
기능을 유니 코드 데이터를 게시하려고 : 내가 잘못httplib을 사용하여 유니 코드 문자를 게시하려면 어떻게합니까?
Traceback (most recent call last):
File "C:\Scripts\iQuality\test.py", line 47, in <module>
print spellFix(u"╫á╫נ╫¿╫ץ╫ר╫ץ")
File "C:\Scripts\iQuality\test.py", line 26, in spellFix
con.request("POST", "/tbproxy/spell?lang=%s" % lang, data)
File "C:\Python27\lib\httplib.py", line 955, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 989, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 951, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 815, in _send_output
self.send(message_body)
File "C:\Python27\lib\httplib.py", line 787, in send
self.sock.sendall(data)
File "C:\Python27\lib\ssl.py", line 220, in sendall
v = self.send(data[count:])
File "C:\Python27\lib\ssl.py", line 189, in send
v = self._sslobj.write(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 97-102: or
dinal not in range(128)
:
s = u"עברית"
data = """
<spellrequest textalreadyclipped="0" ignoredups="1" ignoredigits="1" ignoreallcaps="0">
<text>%s</text>
</spellrequest>
""" % s
con = httplib.HTTPSConnection("www.google.com")
con.request("POST", "/tbproxy/spell?lang=he", data)
response = con.getresponse().read()
그러나이 내 오류가?
XML 선언을 생략해도 좋습니다. 비 UTF 인코딩 또는 XML 1.1을 원할 때만 필요합니다. – bobince
XML 선언을 보내면 Google에서 실제로 오류를 반환합니다. – iTayb
@iTayb : 오류는 어떻게 생깁니 까? 그것은 내 컴퓨터에서 잘 작동했습니다. – SingleNegationElimination