今天在把Evenote的笔记内容写为文件时出错:
f.write(content)
UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 135: illegal multibyte sequence
UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 135: illegal multibyte sequence
经过调查,发现应该在打开文件时设置编码格式。
解决办法:
f = open(n.guid, "w+", encoding='utf-8-sig')