源代码为:
data_file = open("F:\\MyPro\\data.yaml", "r", encoding='utf-8')
运行的时候报错:TypeError: 'encoding' is an invalid keyword argument for this function
我使用的是Python 2.7
这个是版本的问题,需要引入IO模块,调用io的open函数,代码更新如下:
import io
data_file = io.open("F:\\MyPro\\data.yaml", "r", encoding='utf-8')