解决UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x80 in position 0: illegal multibyte sequence问题

1、解决Python报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 658: illegal multibyte

with open(in_file, 'r') as f:

改成

with open(in_file, 'r',encoding='utf-8') as f:

2、解决UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 0: illegal multibyte sequence问题

with open(in_file, 'r') as f:

改成

with open(in_file, 'rb') as f:

你可能感兴趣的:(代码bug,开发语言,python)