parsing engineering symbols
Larry Bates
larry.bates at websafe.com
Tue Dec 20 09:05:36 EST 2005
Something like:
def cvt(input):
if input.lower().endswith('k'): return float(input[:-1])*1000
.
. add your other special symbols here
.
return None # didn't find a match
Larry Bates
Suresh Jeevanandam wrote:
> Hi,
> I want to convert a string to float value. The string contains
> engineering symbols.
> For example,
>
> s = '12k'
>
> I want some function which would return 12000
> function(s)
> => 12000.0
> I searched the web, but could not find any function.
>
> regards,
> Suresh
More information about the Python-list
mailing list