2017-04-14 10 views
-1

私はpython(3.6)で単語を数えるプログラムを書いていますが、コードは端末から円滑に実行されます。しかし、IDLEのPythonを使用すると、以下のエラーが発生します。についてUnicodeDecodeError

Traceback (most recent call last): 
File "/Users/zhangchaont/python/Course Python Programming/6.7V2.py", line 122, in <module> 
    main() 
File "/Users/zhangchaont/python/Course Python Programming/6.7V2.py", line 21, in main 
    for line in txtFile: 
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode 
    return codecs.ascii_decode(input, self.errors)[0] 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 33: ordinal not in range(128) 

解決方法?

+2

コードを入力してください – brennan

答えて

0

あなたのコードについての情報はあまりありません。コーデックの代わりにこのパッケージを使うこともできます。 https://github.com/iki/unidecode。以下の方法で問題を解決する必要があります。 openメソッドでファイルを開き、file_handle.read()

unidecode.unidecode_expect_nonascii(string)