【Python】UnicodeDecodeError: gbk codec can not decode byte 0xa7 in position 8: illegal multibyte

错误: UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 8: illegal multibyte 

错误信息:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa7 in position 8: illegal multibyte 

错误原因:

with open('space list.txt', 'r') as f:
    for line in f.readlines():

解决方法:

with open('space list.txt', 'r',encoding='UTF-8') as f:
    for line in f.readlines():

 

你可能感兴趣的:(Python)