[Tutor] no rsplit
Kent Johnson
kent37 at tds.net
Sun Aug 21 19:44:59 CEST 2005
Write your own?
>>> def rsplitx1(s):
... try:
... i = s.rindex('x')
... return s[:i], s[i+1:]
... except ValueError:
... return s
...
>>> rsplitx1('64x43x12')
('64x43', '12')
>>> rsplitx1('64x43x')
('64x43', '')
>>> rsplitx1('64')
'64'
Kent
Jonas Melian wrote:
> v = "64x43x12" -> '64x43', '12'
>
> How split it by the las 'x'?
>
> In 2.4 it could be used rsplit("x",1)
>
> but i've 2.3.5
>
> Is there another way of splitting a string from the end?
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list