1, in python2.x raw_input () and input (), two functions are present, wherein the difference is
-
Input ()-----can only receive input of "number", has its own attribute when dealing with pure digital input, it returns the type of the number entered (int,float)
2. Raw_input () and input () are integrated in python3.x, removing raw_input (), leaving only the input () function, which receives arbitrary input, defaults all input to string processing, and returns a string type. (examples here are in the PYTHON3 environment)
Example 1:
Name=input () # lets the user enter a string of name and save it in the name variable. Print(' you just entered%s'# shows the string you just entered, %s is a string escape
Output:
Jeffery, you just entered Jeffery.
Example 2:
Name=input () # Let the user enter the name print('Hello', name)
Output:
Jefferyhello Jeffery
3.Python implements multiple values for one line input
# The string a == = = A + B + cprint(d) is saved in A,b,c
To store integers directly in a,b,c:a,b,c = map (Int,input (). Split ())
4.Str.format () function to format output values
Str.format () can make the output more diverse
Example:
forXinchRange (1, 3): Print('{0:2d} {1:3d} {2:4d}'. Format (x, X*x, x*x*x))?Print('{} URL: ' {}! ''. Format ('Baidu','www.baidu.com'))Print('{1} URL: ' {0}! ''. Format ('Baidu','www.baidu.com'))
Output:
1 1 4 8"www.baidu.com! " " Baidu! " "
The basic use of Str.format () is as follows:
The parentheses and the characters inside them (called formatted fields) are replaced by the parameters in format ().
The number in parentheses is used to point to the position of the incoming object in format ().
Python input/output