Python の宿題ここで答えます Part 1
at TECH
[
2ch
|
▼Menu
]
■コピペモード
□
スレを通常表示
□
オプションモード
□このスレッドのURL
■項目テキスト
550:デフォルトの名無しさん 08/02/15 18:36:44 >>503 >>504 >>509 >>525 さらに追加 WingIDEで日本語表示した場合。 >>> 'あいう' '\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86' >>> print 'あいう' 縺ゅ>縺・ >>> u'あいう' u'\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86' >>> print u'あいう' Traceback (most recent call last): File "<string>", line 1, in <string> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-8: ordinal not in range(128) Gui板はPythonWinもWingIDEも自動ユニコードにならないが、 とりあえず日本語表示できた。 >>543 WingIDEがutf-8で入力、出力はユニコードもシフトJISもいけて その上Windowsと同じでソースコードはシフトJIS、ユニコード両方、UTF-8全部いけちゃうのは知ってた? 551:デフォルトの名無しさん 08/02/15 18:41:56 おっと早とちり。 出力はシフトJISだけか・・・ 入力はutf-8なのになあ・・・ >>> unicode('あいう','utf-8') u'\u3042\u3044\u3046' >>> print unicode('あいう','utf-8') Traceback (most recent call last): File "<string>", line 1, in <string> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) >>> print unicode('あいう','utf-8').encode('sjis') あいう >>> print unicode('あいう','utf-8').encode('utf-8') 縺ゅ>縺・
次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
レスジャンプ
mixiチェック!
Twitterに投稿
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch
5386日前に更新/195 KB
担当:undef