Remove integer from float number

Grant Edwards grante at visi.com
Thu Mar 23 17:10:35 EST 2006


On 2006-03-23, Arne Ludwig <arne at citde.net> wrote:
> With that terse description and the subject line I would interpret the
> OP like so:
>
>>>> print re.sub(".*\.",".","0.666")
> .666
>>>> print re.sub(".*\.",".","123.666")
> .666

Or if you're allergic to regular expressions:

>>> print "." + "0.666".split(".")[-1]
.666
>>> print "." + "123.666".split(".")[-1]
.666
>>> 



-- 
Grant Edwards                   grante             Yow!  Yow! It's a hole
                                  at               all the way to downtown
                               visi.com            Burbank!



More information about the Python-list mailing list