Converting exponential to float

前端 未结 6 1434
余生分开走
余生分开走 2020-12-18 08:55

This is my code, trying to convert the second field of the line from exponential into float.

outputrrd = processrrd.communicate()
(output, error) = outputrrd         


        
6条回答
  •  粉色の甜心
    2020-12-18 09:10

    The reason is the use of comma in 6,0865000000e-01. This won't work because float() is not locale-aware. See PEP 331 for details.

    Try locale.atof(), or replace the comma with a dot.

提交回复
热议问题