python: unicode problem

后端 未结 3 1651
隐瞒了意图╮
隐瞒了意图╮ 2021-02-14 11:02

I am trying to decode a string I took from file:

file = open (\"./Downloads/lamp-post.csv\", \'r\')
data = file.readlines()
data[0]
3条回答
  •  情话喂你
    2021-02-14 11:28

    This file is a UTF-16-LE encoded file, with an initial BOM.

    import codecs
    
    fp= codecs.open("a", "r", "utf-16")
    lines= fp.readlines()
    

提交回复
热议问题