String to Float, without introducing errors

Mats Wichmann mats at wichmann.us
Sat Dec 17 13:41:32 EST 2022


On 12/17/22 07:15, Thomas Passin wrote:
> You have strings, and you want to end up with numbers.  The numbers are 
> not integers.  Other responders have gone directly to whether you should 
> use float or decimal as the conversion, but that is a secondary matter.
> 
> If you have integers, convert with
> 
> integer = int(number_string)
>> -64550.727

they pretty clearly aren't integers:

>> -64511.489
>> -64393.637
>> -64196.763
>> -63920.2
>> -63563.037
>> -63124.156
>> -62602.254
>> -61995.895
>> -61303.548
>> -60523.651
>> -59654.66


More information about the Python-list mailing list