split
Kalle Svensson
kalle at gnupung.net
Tue May 8 12:48:05 EDT 2001
Sez Martin Johansson:
> I have a string s that contains "( 7 Maj 21:58)"
> and i want to save 7 Maj in a variable named date.
> But I dont understand what I suppose to write in the split method.
> date = string.split(s, "( ", ")")
date = string.join(string.split("( 7 Maj 21:58)")[1:3], " ")
string.split only uses one separator.
Also note that in Python 2.0 and later, string methods are prefered.
date = " ".join("( 7 Maj 21:58)".split()[1:3])
Peace,
Kalle
--
Email: kalle at gnupung.net | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
[ Not signed due to lossage. Blame Microsoft Outlook Express. ]
More information about the Python-list
mailing list