python中open读取文件编码错误,怎么办?
Posted kimkat
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python中open读取文件编码错误,怎么办?相关的知识,希望对你有一定的参考价值。
比如你只需要提取文件中的手机号,而这些文件的编码都不相同,这时,可以这样:
f = open(filename,‘r,encoding=‘utf-8‘,errors=ignore)
content = f.read()
#do something with content
f.close()
以上是关于python中open读取文件编码错误,怎么办?的主要内容,如果未能解决你的问题,请参考以下文章