So I have a txt file that is written in Farsi and I want to split it word by word and put it in a list, which means I am going to have a list of Farsi words. The error I get:
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: character maps to
code:
text_list = []
f = open('random.txt', encoding='utf-8')
text = f.read().split(' ')
for i in range(0, len(text)):
text_list.append(text[i])
print(text_list)
Also, I've tried: pip install win-unicode-console Then:
try:
from win_unicode_console import enable
enable()
except ImportError:
pass
It didn't work, Any suggestions??