如何格式化“ 6.5”浮动为“ 06.5000”与领先的零?
我想以06.5000
的数据格式输出浮点数数组。
Python有没有办法将小数点和小数点的左侧缩小,例如Awk的printf
,还是Matlab的fprintf
?
我在网上发现的大多数Python建议只是控制小数点右侧的信息。
I want to output the float value array to a CSV-File in a data format like 06.5000
.
Is there a way in Python to trim the decimal point and to the left of the decimal point, like awk's printf
, or matlab's fprintf
?
Most of the Python advice I found on the net was only to control information to the right of the decimal point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该有效:
0
指示零指数,7
是格式化号码字符串的总长度,.4f
是四个小数。浮标的地方。This should work:
The
0
indicates a leading zero, the7
is the total length of the formatted number string and.4f
is the four decimal places of your float.