Python ファイルの文字コード
ソースコード・エンコーディング
#!Python2.6 # -*- coding: utf-8 -*-
- 以下のようなエラーが出る場合、上記対処
SyntaxError: Non-ASCII character '\xe3' in file test.py on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
文字コードを指定して、ファイルを開く
import codecs fd = codecs.open(search_result_file, 'r', 'shift_jis') for l in fd: print l
YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto
Copyright© 矢木 浩人 All Rights Reserved.