admin管理员组

文章数量:1611196

解决UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa7 in position 85: illegal multibyte sequence

代码
in_file = open(r'..\Annotations\%s.xml' % 
(image_id))
报错信息
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 85: illegal multibyte sequence
解决办法
in_file = open(r'..\Annotations\%s.xml' % 
(image_id), encoding='UTF-8')

open打开xml文本,声明Encoding编码方式UTF-8

欢迎大家交流学习,任何问题都可以留言

本文标签: DecodebyteCodecUnicodeDecodeErrorgbk