delimiting text file??
Preston Landers
prestonlanders at my-deja.com
Mon Oct 18 14:12:18 EDT 1999
The suggestions other people have posted will work. Probably the best
way is to have the parts of the string in a list and string.join them.
This is probably the most efficient (though I haven't done benchmarks
or anything.)
Here is the quick and dirty way:
s = some_string
pos = given_position
delimiter = ","
new_string = "%s%s%s" % (s[:pos], delimiter, s[pos:])
good luck,
---Preston
In article <3804F889.30739C22 at bruer.org>,
Jim Bruer <jim at bruer.org> wrote:
>
> How do you insert a delimiter into a string at a given position?
--
|| Preston Landers <prestonlanders at my-deja.com> ||
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list