Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ou\ufef读取Python中的文件?_Python_Input - Fatal编程技术网

如何使用ou\ufef读取Python中的文件?

如何使用ou\ufef读取Python中的文件?,python,input,Python,Input,我的代码 这是我在Jupyter笔记本里的东西 lines=[] with open('biznism.txt') as outfile: for line in outfile: line = line.strip() lines.append(line) 我将使用文件内容进行文本分析,这\ufeff会把事情搞得一团糟。 如何摆脱它?您应该使用正确的编码打开文件,例如: ["\ufeffIf we are all here, let's get sta

我的代码

这是我在Jupyter笔记本里的东西

lines=[]
with open('biznism.txt') as outfile:
    for line in outfile:
        line = line.strip()
        lines.append(line)
我将使用文件内容进行文本分析,这\ufeff会把事情搞得一团糟。
如何摆脱它?

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

["\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.",


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

["\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.",


U+FEFF是零宽度不间断空格,十进制:65279,HTML:无可视表示,UTF-8:0xEF 0xBB 0xBF,block:Arabic Presentation Forms-B,这意味着该符号在文件中。您可以手动删除它,也可以使用正则表达式忽略不可打印的字符,编码有帮助,但我应该处理不可打印的字符。U+FEFF是零宽度不间断空格,十进制:65279,HTML:无可视表示,UTF-8:0xEF 0xBB 0xBF,block:阿拉伯语表示形式-B,这意味着此符号在文件中。您可以手动删除它,也可以使用正则表达式忽略不可打印的字符,编码有帮助,但我应该处理不可打印的字符。
with open('biznism.txt', encoding='utf-16') as outfile: