xMatz
xMatz

Reputation: 11

Get rid of the '' on a list

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

Answers (2)

keffe
keffe

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

user17453888
user17453888

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

Related Questions