Python Error "TypeError: 'Encoding' Is An Invalid Keyword Argument For This Function"
I have a tine code snippet and it gives me the following error:
TypeError: 'encoding' is an invalid keyword argument for this function
code:
import numpy as np
trump = open('speeches.txt', encoding='utf8').read()
# display the data
print(trump)
Regarding the typeerror: 'encoding' is an invalid keyword argument for this function -
using io.open() instead of open removed this error for me eg:
import io
with io.open('gaeilge_flashcard_mode.txt','r', encoding='utf8') as file:
for line in file:
line1 = line.rstrip().split("=")
key = line1[0]
trans = line1[1]
PoS = line1[2]
Flashcards(key, trans, PoS)