python 2.7版本解决TypeError: 'encoding' is an invalid keyword argument for this function

来源:互联网 发布:程序员交流圈 编辑:程序博客网 时间:2024/06/04 10:57

data_file = open(“F:\MyPro\data.yaml”, “r”, encoding=’utf-8’)

运行的时候报错:TypeError: ‘encoding’ is an invalid keyword argument for this function

网上查找一番后,改成如下这样就可以搞定
import io

data_file = io.open(“F:\MyPro\data.yaml”, “r”, encoding=’utf-8’)

阅读全文
0 0