string in files
Lie Ryan
lie.1296 at gmail.com
Tue Dec 30 08:24:18 EST 2008
On Tue, 30 Dec 2008 11:53:17 +0100, Glauco wrote:
>> thanks brother
>> i mean how do i particularly assign (u = this)
>> (y = is)....
>> in the strings up there. i have been able to split strings with any
>> character sign.
>>
>>
>
> If i'm not wrong this is simple with RE:
>
Using Regular Expression for this is an overkill, you'd better use the
str.split:
longstring = 'this is a python string'
splitted_string = longstring.split()
result = ', '.join(splitted_string[:-1]) + ' and ' + splitted_string[-1]
More information about the Python-list
mailing list