2011-10-17 6 views
0

他の検索エンジンを使用してカスタマイズされた検索Webページを構築します。好き。サーバー側でクライアント側AM用英語以外の単語を渡しているときにpython uni-code serverエラーが発生しました

検索語をエンコードし、

http://xxx.appspot.com/search?q=encodeUIComponent(qTermsを使用して自分のサーバーに送信)

(AppEngineの - Pythonは)qTerms= urllib.unquote_plus(qTerms)

ようurllibは

を使用してテキストをデコードしています

また、私はstermsをコード化しました。 qTerms= urllib.quote_plus(qTerms)

私はqTermstoを私のサーバーから別のサーバーに送信し、xml応答を取得します。

Traceback (most recent call last): 
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py",   line 701, in __call__ 
    handler.get(*groups) 
    File "/base/data/home/apps/s~searchepic/1.353951740301902288/search.py", line 124, in get 
    qTerms = urllib.quote_plus(qTerms) 
    File "/base/python_runtime/python_dist/lib/python2.5/urllib.py", line 1222, in quote_plus 
    return quote(s, safe) 
    File "/base/python_runtime/python_dist/lib/python2.5/urllib.py", line 1214, in quote 
    res = map(safe_map.__getitem__, s) 
KeyError: u'\u0c15' 

答えて

2

あなたが引用符()ASCII(文字列)文字列の代わりに、Unicode文字列を渡す必要があります:私はその引けるエラー以下のような非英語の単語を渡すとき

上記のデザインは、純粋なengilsh言葉に適しています。
あなたはterm.encode('utf8')に電話し、結果を引用符で()に渡す必要があります

+0

YAHは働いてくれてありがとうございますu – user578542

+0

ANSI?私は1982年にタイムワープに入ったのですか? –

関連する問題