Wednesday, 22 January 2020

Python ERROR : ValueError: I/O operation on closed file.



For a quick fix, save the standard stdout in a different variable, then redirect to it after that close.

# Simple image to string

saved_stdout = sys.stdout
sys.stdout = open('file.txt', 'w')
print (pytesseract.image_to_string(Image.open('Ke.png')))
sys.stdout.close()

sys.stdout = saved_stdout

No comments:

Post a Comment

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...