如何在没有 \ufef 的情况下在 Python 中读取文件?

Ric*_*lev 1 python input

我的代码

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

这是我的 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.",
Run Code Online (Sandbox Code Playgroud)

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

And*_*eas 5

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

with open('biznism.txt', encoding='utf-8-sig') as outfile:
Run Code Online (Sandbox Code Playgroud)

或者

with open('biznism.txt', encoding='utf-16') as outfile:
Run Code Online (Sandbox Code Playgroud)