Python报各种异常的解决方法--持续更新

一、UnicodeEncodeError: 'gbk' codec can't encode character '\xbb' in position 12305: illegal multibyte sequence

原始程序

 f = open(FileName, "a")
    f.write(message)

在写入一些字符时,报错,

参考地址:

https://blog.csdn.net/Dillon2015/article/details/53204955

https://blog.csdn.net/hw140701/article/details/52044905

解决方法:

 f = open(FileName, "a", encoding='gb18030')
    f.write(message)

猜你喜欢

转载自blog.csdn.net/samenmoer/article/details/82824243