\ ufef如何在Python中读取文件?

时间:2018-11-07 09:56:09

标签: python input

我的代码

lines=[]
with open('biznism.txt') as outfile:
    for line in outfile:
        line = line.strip()
        lines.append(line)

这就是我的Jupyter笔记本中的东西

["\ufeffIf we are all here, let's get started. First of all, I'd like you to please join me in welcoming Jack Peterson, our Southwest Area Sales Vice President.",
 "Thank you for having me, I'm looking forward to today's meeting.",
 "I'd also like to introduce Margaret Simmons who recently joined our team.",
 'May I also introduce my assistant, Bob Hamp.',
 "Welcome Bob. I'm afraid our national sales director, Anne Trusting, can't be with us today. She is in Kobe at the moment, developing our Far East sales force.",

我将使用文件内容进行文本分析,这\ ufeff会让您一团糟。 如何摆脱它?

1 个答案:

答案 0 :(得分:1)

您应使用正确的编码打开文件,例如:

with open('biznism.txt', encoding='utf-8-sig') as outfile:

with open('biznism.txt', encoding='utf-16') as outfile: