1

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)
2
  • 1
    Your code probably needs to be fixed, but without seeing what that code is, what kind of answer are you expecting? Commented Jan 24, 2022 at 19:11
  • My bad, it was the first example from the docs Commented Jan 24, 2022 at 19:13

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.