. Advertisement .
..3..
. Advertisement .
..4..
When I run my tine code snippet, I receive the ”typeerror encoding is an invalid keyword argument for this function”error:
TypeError: 'encoding' is an invalid keyword argument for this function
Here is my code:
import numpy as np
trump = open('speeches.txt', encoding='utf8').read()
# display the data
print(trum
Can someone tell me why this error happens and the way to fix it?
The cause: This error occurs because the open method does not have a parameter with the name encoding and you are using an argument with that name.
Solution: You can solve the problem by using the
io
module. like this:import io