Python3.2 を使用していくつかのファイルを読み取ろうとしていますが、一部のファイルには Unicodeが含まれている場合と含まれていない場合があります。
私がしようとすると:
file = open(item_path + item, encoding="utf-8")
for line in file:
print (repr(line))
エラーが発生します:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 13-16: ordinal not in range(128)
ここのドキュメントに従っています: http://docs.python.org/release/3.0.1/howto/unicode.html
Python がこのコードの任意の時点で ascii にエンコードしようとするのはなぜですか?