I am trying to extract the first words in a file by Python.
My code
import re
con1 = pg.DB('tk', 'localhost', 5432, None, None, 'masi', '123')
f1="/home/masi/fy.txt"
print re.findall(r"\w+", f1.read())
I get the error
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
AttributeError: 'str' object has no attribute 'read'