I have to extract data from resumes. And when I try to extract pincode from resume the below error occurred and I can't rectify it.
I am passing a file object and read through open()
and then saved it to the variable called _datas_
. I am using python 3.6.
Below is the code I used:
import re
def pincode_fetch(pincode):
pincode = re.search(r"^[1-9]\d{5}$", pincode)
return pincode
print(pincode_fetch(datas))
The expected output is like this: "686533"
.
But I got an error like this:
--> 182 return _compile(pattern, flags).search(string)
183
184 def sub(pattern, repl, string, count=0, flags=0):
TypeError: expected string or bytes-like object
import re
pincodesearch = re.compile(r'(\d\d\d\d\d)')
mo = pincodesearch.search('Carnival technopark trivandrum 686533')
print(mo.groups())[0]