python2 && python3 the input function

 

 

Python2.x the input () function
input () function Let us be clear that we enter the digital format or character format, is that we have to know what we want, directly into digital format, character format must be in single quotes or double quotation marks, to determine our input string.

 


Raw_input Python2.x in () function:
>>> A = the raw_input ( "Please INPUT your name:")
Please INPUT your name: Virgin
>>> A
'Virgin'
>>> A = the raw_input ( "Please your Favorite INPUT number: ")
Please iNPUT your Favorite number: 10
>>> a
'10'
for the first time we enter a string, and is not quoted, the Virgin normally assigned to the variable a; second digital input 10 However, when the output, a is a character format '10', this time the system will default to the digital input of our text, it can be seen, the raw_input () function no matter what the user input, default to character format; the input ( ) function in Python2.x, the user is to determine what you've entered, the user should clearly understand what they themselves manipulated Yes.

 

 


Python3 the input () function:
We know that in Python3 is no raw_input () function, only input () function, because Python3 optimization and integration is on the line:
input () function

INPUT = A >>> ( "Please INPUT your favoriete Number:")
Please INPUT your favoriete Number: 10
>>> A
'10'
>>> INPUT B = ( "Please INPUT your name:")
Please INPUT your name: Virgin
>>> B
'Virgin'
we first input is digital, this time, iNPUT () is the number 10 as text to variables a, second, we text to variables B, the output the result is a text, which Python2 in raw_input () is the same, so, in Python3 is the Python2 the input () is deleted, the name raw_input () is changed to the input () function, so we use numbers when you need to convert their own, so when we let the user enter numbers must avoid to be converted, if we want to use digital technology.

 

Reference:
https://www.cnblogs.com/gengcx/p/6707024.html

 

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11210292.html