"Dave Angel" <da...@ieee.org> wrote
If your tokens are separated by whitespace, you can simply use a single call to split(). It will turn a single string into a list of tokens.

line = "Now   is the time"
print line.split()

will display the list:
['Now', 'is', 'the', 'time']

And if it's not separated by whitespace you can supply the separator, eg a colon:

line.split(':')

For more sophisticated functionality use the re module or a specialised parser.


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


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

Reply via email to