python - 如何使用 OCR Pytesseract 删除文本提取后出现的箭头符号
问题描述
嗨,我正在使用坐标从简历中提取一些文本。从 OCR Pytesseract 提取文本后,每次将文本写入 txt 文件后都会弹出一个箭头
这是我的代码
import cv2
import numpy as np
import pytesseract
import threading
image = cv2.imread(r'C:\Users\Ramesh\Desktop\Parsing_Project\Resumes_jpg\Akhil\Akhil.jpg')
image = cv2.resize(image,(800,740))
kernel = np.array([[-1,-1,-1],
[-1, 9,-1],
[-1,-1,-1]])
sharpened = cv2.filter2D(image, -1, kernel)
f = open(r'C:\Users\Ramesh\Desktop\Parsing_Project\result_text.txt', "a")
def designation(image):
designation_cropped = image[65
:90, 290:600]
text = pytesseract.image_to_string(designation_cropped).replace(',', ' ')
print(text)
f.write(text + '\n' )
def skills(image):
skills_cropped = sharpened[110:210, 10:220]
text = pytesseract.image_to_string(skills_cropped).replace(',', ' ')
print(text)
f.write(text + '\n' )
f.close()
threading.Thread(target =designation(image)).start()
threading.Thread(target =skills(image)).start()
这是提取的文本片段。每次我将文本写入 txt 文件时,都会看到一个箭头
我想摆脱箭头标志。有人可以帮我吗?
解决方案
大家好,我找到了解决方案
我用了
text.replace('\f','')
这删除了我的结果中捕获的箭头
推荐阅读
- javascript - 如何在 D3.js v4 中实现多个不同方向的树?
- java - 计算列表中元素的数量并将其附加到每个项目的末尾并保持要返回的列表中的插入顺序?
- java - Java:将 4 个单独的音频字节数组组合成单个 wav 音频文件
- jquery - jquery-raty 没有显示任何星星
- sugarcrm - 为什么每当我们在系统中创建新用户时,vtiger 都会在 user_privilege 中创建新的 .php 文件
- python - 试图返回一个字典,而不是得到一个
- python - 根据字符串python的开始关键字和结束关键字切割一个字符串
- android - 如何使用相对布局将小部件约束到末尾和顶部
- node.js - 为什么 crypto.pbkdf2Sync 在 Node JS 中的 setTimeout() 之前执行?
- reactjs - 用 setTimeout 测试钩子状态更新