昨天用用python3写个日志文件,结果报错UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 30: illegal multibyte sequence
具体代码是:
with open(fileName, 'a') as f:
f.write(message)
后来改成如下:
with open(fileName, 'a',encoding='utf-8') as f:
f.write(message)
就可以了。还是编码的问题