[Tutor] file methods
john at fouhy.net
Tue Jul 10 03:04:20 CEST 2007
On 10/07/07, bhaaluu <bhaaluu at gmail.com> wrote:
> >>> file.readlines()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: 'str' object has no attribute 'readlines'
This error here is caused by this earlier statement:
> >>> file=open('text.txt').read()
'file' is now a string, not a file-like object. This also causes the
behaviour you get when iterating 'for line in file'...
More information about the Tutor