读取文本文件时出现:
binary mode doesn't take an encoding argument
原因是在使用二进制模式下是不能设置编码,去掉b就可以了
before:
with open('result.txt', 'rb',encoding="utf8") as f:
chars =data = f.read()
after:
with open('result.txt', 'r',encoding="utf8") as f:
chars =data = f.read()