# -*- coding: utf-8 -*-
import os
import time
from PIL import Image
import pytesseract
OLD=[]
NEW=[]
def file_name(file_dir):
L=[]
for root, dirs, files in os.walk(file_dir):
for file in files:
if os.path.splitext(file)[1] == '.jpeg':
L.append(os.path.join(root, file))
return L
fileName=file_name('C:\\Users\\Administrator\\ftp')
print(fileName)
#a.sort()排序
NEW.sort()
while True:
NEW=file_name('C:\\Users\\Administrator\\ftp')
c = [x for x in NEW if x in OLD]
d = [y for y in (NEW+OLD) if y not in c]
print(d)
for i in range(d.__len__()):
print(d[i])
text=pytesseract.image_to_string(Image.open(d[i]),lang='chi_sim')
print(text)
file=open(d[i]+'.txt','w')
file.write(text);
file.close()
time.sleep(2)
OLD = NEW
跟新显示文件并将文件转换成文字保存txt文件
猜你喜欢
转载自blog.csdn.net/weixin_33595571/article/details/84959939
今日推荐
周排行