How to format output numbers in python
In this issue, the editor will bring you about how to format the output numbers in python. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1. Keep decimal places
Format (parameter 1, parameter 2)
Parameter 1: the number to be formatted
Parameter 2: format string to indicate how to format
Use the format as an example:
Format (x, "20.2f") can add 0 in front of the data to form 000000000000123.46
> > xylene 1357.45667
> print (format (x, ","), 111)
1357.45667 111
Thousand semicolon + decimal point reserved
Format (x, ", .2f")
Scientific counting method
Format (x, "e")
Scientific counting + retention of decimal point
Format (x, "0.2e")
III. Scientific counting method
The integer 12345 is expressed as 1.2345 * (10 to the fourth power) by scientific counting.
In a computer, the power of 10 can be expressed as the power of e:
The fourth power of 10, expressed as eigen4 in the computer.
10 to the power of-4, expressed as eMur4 in the computer
The above is how to format the output numbers in the python shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.