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


import numpy as np

trump = open('speeches.txt', encoding='utf8').read()
# display the data
Aug 1 in Python by Harshit

1 answer to this question.

0 votes

Trying using the io module for this purpose. 

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

Related Questions In Python

0 votes
1 answer

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,520 points
+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
• 56,900 points

edited Aug 21, 2018 by Omkar 145 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,520 points
+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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 281 views
+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 in Python by rahul
• 200 points
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 in Python by Harish