TypeError: 'encoding' is an invalid keyword argument for this function

Posted 北门吹雪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: 'encoding' is an invalid keyword argument for this function相关的知识,希望对你有一定的参考价值。

python 2.7 问题

 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‘)

  

 

以上是关于TypeError: 'encoding' is an invalid keyword argument for this function的主要内容,如果未能解决你的问题,请参考以下文章

TypeError: ‘encoding‘ is an invalid keyword argument for this function

TypeError: ‘encoding‘ is an invalid keyword argument for this function

python读文件,TypeError: a bytes-like object is required, not 'str'

TypeError: a bytes-like object is required, not 'str'

Python错误:TypeError:'str' does not support the buffer interface

TypeError: the JSON object must be str, not 'bytes'