Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Python 3.1 中有以下代码
"{0:.6E}".format(9.0387681E-8)
这给出了一个字符串9.038768E-08,但我想要删除9.038768E-8 前导 0的字符串。E-08我该怎么办?
9.038768E-08
9.038768E-8
E-08
你可以做这样的事情
"{0:.6E}".format(9.0387681E-8).replace("E-0", "E-")
或者像 JBernardo 建议的那样更好
format(9.0387681E-8, '.6E').replace("E-0", "E-")
E+0如果你有大数字,你也需要更换
E+0