In a message of Fri, 27 Nov 2015 17:05:21 +0530, "Br. Sayan" writes:
>How can we read specific lines from a text files using python. File
>attached.
>
>Suppose we want to read lines starting with 'R|1|^^^' and 'O|1|'
>
>Should we use:
>
>line.startswith(("..", "..", "----"))

that matches lines that start with '..'  or '..' or '----'
so whatever else is going on, there is no need to repeat.

If that is what is literally found in the file then
line.startswith(('R|1|^^^','O|1|'))
ought to match them.  But if that syntax means something else, i.e
an R, followed by a 1, followed by any 4 characters, then you will
have to explain what the syntax means.

Laura

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to