版权声明:本文为博主原创文章,欢迎转载,请注明出处 https://blog.csdn.net/mouday/article/details/84401607
python 2.7版本
data_file = open("data.txt", "r", encoding='utf-8')
运行的时候报错:
TypeError: 'encoding' is an invalid keyword argument for this function
解决:
import io
data_file = io.open("data.txt", "r", encoding='utf-8')
参考
python 2.7版本解决TypeError: ‘encoding’ is an invalid keyword argument for this function