UnicodeEncodeError: ‘gbk‘ codec can‘t encode character ‘\u2022‘ in position 178: illegal multibyte s

UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 178: illegal multibyte s

保存json文本文件报错,解决方式加一个忽略错误就可以正常运行

    with open(file, "w", encoding="gbk",errors='ignore') as f:
        json.dump(data, f, ensure_ascii=False, indent=4)

你可能感兴趣的:(python,python)