On Mon, Jan 11, 2010 at 2:33 AM, sudhir prasad wrote:
> hi,
> what is the equivalent function to strtok() in c++,
> what i need to do is to divide a line into different strings and store them
> in different lists,and write them in to another file
To split on a single character or a fixed sequence
"Stefan Behnel" wrote
For more sophisticated functionality use the re module or a specialised
parser.
Just a quick note here, "specialised parser" might sound like something
that's hard to write. It's not.
Good point. I meant one of the many existing parsing packages for
specific purposes
Alan Gauld, 11.01.2010 10:07:
For more sophisticated functionality use the re module or a specialised
parser.
Just a quick note here, "specialised parser" might sound like something
that's hard to write. It's not. There are quite some parser packages
available for Python that are easy to use.
"Dave Angel" 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
sudhir prasad wrote:
hi,
what is the equivalent function to strtok() in c++,
what i need to do is to divide a line into different strings and store them
in different lists,and write them in to another file
If your tokens are separated by whitespace, you can simply use a single
call to split(
hi,
what is the equivalent function to strtok() in c++,
what i need to do is to divide a line into different strings and store them
in different lists,and write them in to another file
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subsc