python 3.6从服务器解码文本

时间:2018-03-21 16:24:07

标签: python file text decode

我在服务器上运行python代码(python 3.6)。它试图读取具有以下结构的csv文件:

I'll    510 676 1   Speaker2
come back   727 878 3   Speaker2
and wake you    930 1196    3   Speaker2
sp  1196    1242    99  Speaker2
in twenty   1109    1401    3   Speaker2
to  1544    1631    1   Speaker2
give you    1631    1952    3   Speaker2

这段代码:

with open(csvfile, 'r') as f:
   lines = f.readlines()

返回此错误:

UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 15-16: invalid continuation byte

我尝试了thisthis,但它无效

1 个答案:

答案 0 :(得分:0)

问题在于它不是真正的CSV。当我再次保存为CSV时,它有效!