AttributeError Problem
Skip Montanaro
skip at pobox.com
Tue Apr 23 20:02:08 EDT 2013
> numberOfVertices = int(infile.readline().decode()) # Read the first line from the file
> AttributeError: 'str' object has no attribute 'readline'
...
> infile = filedialog.askopenfilename()
This is just returning a filename. You need to open it to get a file
object. For example:
infile = filedialog.askopenfilename()
fd = open(infile)
...
numberOfVertices = int(fd.readline().decode())
Skip
More information about the Python-list
mailing list