[Tutor] Import multiple lines of text into a variable

Alan Gauld alan.gauld at btinternet.com
Tue Apr 12 02:41:37 CEST 2011


"Sean Carolan" <scarolan at gmail.com> wrote

> I ended up doing this, but please reply if you have a more elegant 
> solution:
>
> if line.startswith('notes'):
>    break
> notes = open('myfile','r').read().split(notes:\n')[1]

The first two lines are redundant you only need the last one.

HTH,

Alan G. 




More information about the Tutor mailing list