This article is mainly for you to share on the basis of Python text formatting, the method is very detailed, the need for friends can look
1.Python text formatting
In the version of Python 3.0, the input statement defaults to a string (even if the input number is treated as a string), and is coerced into a number: Age=int (Input ("Input your Age:"))
Python2.7 in input and raw_input:
Input in Python3.5, no raw_input function:
1.1 Method One
%s----Reference string, number%d----integer%f----floating point%x----hexadecimal integer
In the place where you need to format the%s instead, the end of the statement with a% (), the parentheses fill in the contents (strings quoted, separated by commas), if there is only one content, you can omit the parentheses.
Program:
Output:
2.2 Method Two
Floor,ceil function-rounding (e.g. 32.9 for 32.0 or 33.0)
Program:
Output:
Program:
Output:
Related recommendations:
Python Basic Tutorial file operations implement full-text or single-line substitution methods
Getting Started with Python basics-Blockchain
Python basic entry-level operations summary