This article mainly shares with you about text formatting in Python basics. The method is also quite detailed. Friends in need can take a look
In the Python 3.0 version, the input statement inputs a string by default (even if you enter a number, it will be treated as a string), and it is forced to be converted into a number: age=int(input("input your age:"))
Python2 .7 input and raw_input:
Replace with %s in the position that needs to be formatted, add %() at the end of the statement, and fill in the content directly in the brackets (The string is quoted and separated by commas). If there is only one content, the brackets can be omitted.
Program:
Output:
##2.2 Method 2
floor, ceil function--rounding (such as 32.9 is taken as 32.0 or 33.0)
Program:
Output:
Program:
Output:
Related recommendations:
The above is the detailed content of Python basics text formatting. For more information, please follow other related articles on the PHP Chinese website!