53932/python-typeerror-encoding-invalid-keyword-argument-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)
Trying using the io module for this purpose.
import io trump = io.open('speeches.txt', encoding='utf8').read()
This should work.
To know more, It's recommended to join our Python Training in Chennai today.
datagen = ImageDataGenerator(zoom_range=0.2,rotaion_range=10,width_shift_range=0.1, height_shift_range=0.1,horizontal_flip=True, vertical_flip = False ...READ MORE
The following are totally acceptable in python: passing ...READ MORE
Hi, good question. The thing is that ...READ MORE
Easiest way: math.factorial(x) (available in 2.6 and ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
The with statement in Python simplifies exception ...READ MORE
Hi @Kashish, try something like this: for i ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.