Convert float number to string with engineering notation (with SI prefix) in Python

后端 未结 5 1506
离开以前
离开以前 2021-01-12 20:16

I have a float number such as x=23392342.1

I would like to convert it to a string with engineering notation (with metric prefix)

http://en.wikip

5条回答
  •  野的像风
    2021-01-12 20:49

    A direct solution is to use the Decimal.to_eng_string method and then do a dictionary lookup to convert the exponent to appropriate metric prefix.

提交回复
热议问题