报错: UnicodeEncodeError: 'gbk' codec can't encode character '\xd0' in position 70: illegal multibyte

报错:

UnicodeEncodeError: 'gbk' codec can't encode character '\xd0' in position 70: illegal multibyte sequence

解决:

with open(filename, 'a') as fobj:
    fobj.write(data)

改为:

with open(filename, 'a', encoding='utf-8') as fobj:
    fobj.write(data)

参见:
https://blog.csdn.net/qq_38008452/article/details/80423436

你可能感兴趣的:(python)