3
나는 매개 변수 목록 인코딩하기 위해 다음 코드를 사용 :한자를 URL 인코딩하는 방법은 무엇입니까?
params['username'] = user
params['q'] = q
params = urllib.quote(params)
을하지만 q
가 香港
같을 때 작동하지 않습니다. 다음 오류가 반환됩니다.
'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
어떻게 수정해야합니까?
:
# encoding: utf-8
를 추가quote
여기 예제 제 생각에는, 변환기 유니 코드가 아스키 예제 인'\\ u524d'가 필요합니다. 또는 http://stackoverflow.com/questions/2365411/python-convert-unicode-to-ascii-without-errors를 확인하십시오. – KingRider