Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TypeError: input() got an unexpected keyword argument 'encoding'

I got the following error: TypeError: input() got an unexpected keyword argument 'encoding' when trying to read from stdin in python using fileinput.input(), but the documentation says file input should be used like that.

I’m using python 3.9

import fileinput
for line in fileinput.input(encoding="utf-8"):
    process(line)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In Python 3.9, fileinput.input() does not take an encoding argument (see here). That argument was introduced in Python 3.10:

Changed in version 3.10: The keyword-only parameter encoding and errors are added.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading