Reputation: 11
Bee n trying to do this all the morning but can't seem to figure it out.
reader = easyocr.Reader(['en'])
result = reader.readtext('image_name.png',blocklist="'",detail=0)
the output given is always some numbers with the apostrophes. Ex: '300526'. I want to take them out and store the numbers on a single string. Im not able to do str.replace tho because the output given by result() seems to be a list
Upvotes: 1
Views: 85
Reputation: 163
You could just replace the apostrophes by:
result.replace("'", "")
Alternatively you could use regex to remove anything but digits, like:
re.sub(r"\D", "", result)
Upvotes: 3
Reputation:
Just use the replace
function which is a builtin from Python. Based on your example you can use it like this:
result = '300526'
result.replace("'", "")
print(result)
Output:
300526
Upvotes: 1