Python error "TypeError: 'encoding' is an invalid keyword argument for this function"

0 votes

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)
Aug 1, 2019 in Python by Harshit
3,264 views

1 answer to this question.

0 votes

Trying using the io module for this purpose. 

import io
trump = io.open('speeches.txt', encoding='utf8').read()
answered Aug 1, 2019 by Vaishali

Related Questions In Python

+1 vote
6 answers
+1 vote
1 answer

What is the function for Factorial in Python

Easiest way: math.factorial(x) (available in 2.6 and ...READ MORE

answered Aug 21, 2018 in Python by Priyaj
• 57,530 points

edited Aug 21, 2018 by Omkar 272 views
0 votes
1 answer

Is there an expression for an infinite generator in Python?

you can iterate over a callable returning ...READ MORE

answered Nov 20, 2018 in Python by Nymeria
• 3,540 points
443 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,074 views
0 votes
0 answers
+4 votes
6 answers
0 votes
3 answers

What is the python keyword “with” used for?

The with statement in Python simplifies exception ...READ MORE

answered Jul 19, 2019 in Python by rahul
• 360 points
174 views
0 votes
1 answer

Python error "TypeError: range() integer end argument expected, got numpy.float64."

Hi @Kashish, try something like this: for i ...READ MORE

answered May 27, 2019 in Python by Harish
581 views