python - 在没有科学记数法的情况下将 float 转换为字符串

标签 python string casting double scientific-notation

float :

fl = 0.000005

转换为 String 作为 str(fl)=='5e-06'。但是,我希望将其转换为 str(fl)='0.000005' 以便导出为 CSV 目的。

我如何实现这一目标?

最佳答案

您可以只使用标准的字符串格式化选项来说明您想要的精度

>>> fl = 0.000005
>>> print '%.6f' % fl
0.000005

关于python - 在没有科学记数法的情况下将 float 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25665523/

相关文章:

python - 将列表的列表转换为 numpy 数组时保持原始数据类型

python - 使用 numpy 将时间平均值恢复为即时值

python - Ncbi蛋白质数据库,如何从特定生物项目获取蛋白质序列(python脚本)

c# - 当来自字符串时,SqlXml 删除 XML header

c# - 转换和转换是一回事吗?

c# - 在 C# 中使用 IsAssignableFrom 和 "is"关键字

python - 南 : run a migration for a column that is both unique and not null

string - 为什么Scala中的drop()方法允许负值并且不会抛出错误?

arrays - 查找字符串数组中字符串的索引

c++ - 可以将 std::pairs 的 std::vector 转换为字节数组吗?