# -*- coding: utf-8 -*-
import sys
# 標準出力の encoding を表示
print sys.stdout.encoding
print "あ"
print u"あ"
# 各文字の型を表示
print type("あ")
print type(u"あ")
Shift-JIS実行結果
> chcp 現在のコード ページ: 932 > python test00.py cp932 縺 あ <type 'str'> <type 'unicode'>UTF-8
コマンドプロンプトの文字コードを UTF-8 に変更した場合
実行結果
> chcp 65001 Active code page: 65001 > python test00.py cp65001 (文字化け) Traceback (most recent call last): File "test00.py", line 3, inprint u"(文字化け)" LookupError: unknown encoding: cp65001
0 件のコメント:
コメントを投稿