用Python解码文件

时间:2014-12-22 00:52:19

标签: python python-3.x decoding

我遇到编码/解码问题。我根本无法让我的简单程序读取。

def testfunk ():
    filnamn2 = "arbete.txt"
    filnamn = open("arbete.txt", "r")
    utfil = open("arbetad.txt", "w")
    inrad = filnamn.readline()

生成错误代码:

Traceback (most recent call last):
    File "test.py", line 24, in <module>
       testfunk()
    File "test.py", line 9, in testfunk
       inrad = filnamn.readline()
    File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/encodings/ascii.py", line   26, in decode
       return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 29: ordinal not in range(128)

如何简单地解决这个问题?

0 个答案:

没有答案