报错原因:文件打开方式有问题,把之前的打开语句修改为用二进制方式打开就没有问题 with open('lagou.json','wb') as fp: fp.write(line.encode("utf-8"))