Tuesday, 10 March 2020

Python to get only digits from a file and append into a list



            f = open('file2.txt', 'r')
            for line in f:
                    words = line.split()
                    for i in words:
                            if(i.isdigit()):
                                mylist.append(i)
            print (mylist)

take a screenshot with python , convert image into text and save it as a file




try:
    from PIL import Image
except ImportError:
    import Image
import pytesseract
import sys, os
import subprocess
import pyautogui


pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

img1 = pyautogui.screenshot(region=(372,198,1118,682))
img1.save("screenshot1.jpg")


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

Monday, 3 February 2020

Wednesday, 22 January 2020

ERROR : new-object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).



Close admin command prompt console and open with user mode 

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

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...