1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
import shutil
import pytesseract
from PIL import Image
file_type = ['png', 'jpeg', 'bmp', 'gif', 'tif', 'wav']
flag = ''
for i in range(1, 7):
file_txt = str(i) + '.txt'
file_sou = str(i) + '.' + file_type[i-1]
print(file_txt, file_sou)
shutil.copyfile(file_txt, file_sou)
img = Image.open(file_sou)
flag += pytesseract.image_to_string(img,lang='eng')
print(flag.replace('\n', ''))
|