問題タブ [python-unicode]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Python ユニコード エラー
print a
以下の例で例外が発生する理由を誰かが説明できますかa.__str__()
?
python - "\uxxxxxx" 形式の Unicode を文字列またはテキストに変換します
FacebookビデオのURLを抽出するPythonスクリプトを書いています。しかし、ビデオ ページのソースでは、URL に \uxxxxxx の形式の文字がいくつか表示されます。
たとえば、URLはこの形式です
\u00253Aはコロン(:)なのですが、どうやって変換すればいいのでしょうか。
私が好きだったとき
私は得る
パーセンテージではなく正確なURLが必要です。
いろいろ検索しましたが、助けが見つかりませんでした。
前もって感謝します
編集
Facebookページのソース全体を渡してから、そのような複雑なUnicode文字をすべて単純なものに変換する方法はありますか.
python - Python 辞書から Unicode 値を文字列として変換する
次のようにPython辞書を作成しました。
これは、各テーブル (フィーチャ クラス) のフィールドの名前を取得し、tyhem をディクショナリのキー値として設定し、テーブルの名前を値として設定します。私の目標は、同じフィールドを持つテーブルを見つけることであるため、これはうまく機能します。項目を反復処理して、キーと値のペアを出力できます。
戻り値:
コメント: [u'TM_FC', u'GT_FC', u'HG_FC', u'PO_FC', u'FU_FC']
次のようになるように、キー値を Unicode の代わりに文字列値として出力したいと思います。
コメント: 'TM_FC'、'GT_FC'、'HG_FC'、'PO_FC'、'FU_FC'
「str」関数や、書式設定して文字列に変換する他のさまざまな方法を試してきましたが、常に同じ元の値リストを返しています。誰かが私が探しているものを達成する方法を提案できますか?
ありがとう、マイク
python - Popen subprocess does not exit when stdin includes unicode
I am executing a subprocess using Popen
and feeding it input as follows (using Python 2.7.4):
Adding the entry to the environment it is executed with is necessary because the input string includes Japanese characters, and when the script is not executed from the command line (in my case being called by Apache), Python cannot guess the encoding.
This setup has worked fine for me with other commands, however now I'm using chasen
(a Japanese tokenizer), whenever I send it unicode characters the subprocess does not return, and it just sits there with the Python script chewing up memory. This seems like an encoding problem, but I thought I had would have sorted this out by specifying the encoding with the LC_ALL
environment variable.
Edit: Extra weirdness as follows... I don't get this problem when executing the Python script from the command line with the notable exception of the '。' character. For some reason this causes the strangeness from chasen
also.
python - 関数内の Python 2.7 Unicode エラー (__future__ print_function および unicode_literals を使用)
ユニコードに関するいくつかのスレッドを読みました。
私はPython 2.7.2を使用していますが、将来のprint_functionを使用しています(生のprintステートメントは私にとって非常に混乱しているため..)
だからここにいくつかのコードがあります:
今、次のようなものを印刷すると
それは完全に機能します。ただし、はい、私はPythonにまったく慣れていません.Unicode文字列を出力する関数を宣言すると、スクリプトが吹き飛ばされます
このエラーとユニコードを一般的に処理する最良の方法は何ですか? 代わりに 2.7 の print ステートメントを使用する必要がありますか?