UnicodeEncodeError: ‘gbk‘ codec can‘t encode character ‘\u301c‘ in position 2321: illegal multibyte

问题

python写入文件

writer = open('stopwords.txt')

报错

UnicodeEncodeError: 'gbk' codec can't encode character '\u301c' in position 2321: illegal multibyte

解决方案

writer = open('stopwords.txt', 'w', encoding='utf-8')

你可能感兴趣的:(报错解决,Python编程,python)