Python 写文件时的Unicode设置
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')
https://muzizongheng.blog.csdn.net/