is it possible some way to "print" in python in a fortran like way like this?
1 4.5656
2 24.0900
3 698.2300
4 -3.5000
So the decimal points is always in the same column, and we get always 3 or n decimal numbers?
Thanks
>>> '%11.4f' % -3.5
' -3.5000'
or the new style formatting:
>>> '{:11.4f}'.format(-3.5)
' -3.5000'
more about format specifiers in the docs.
You could also take a look at the fortranformat
library on PyPI or the project page if you wanted to fully recreate FORTRAN text IO.
If you have any questions, send me an email (I wrote it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With