Transferred from: http://blog.csdn.net/sruru/article/details/7790436
Previously did not deeply consider the difference between the raw_input and the input function, so has been more confused, today after testing, have a more in-depth understanding, recorded as follows
>>> user = Raw_input ("Enter your name:") Enter your NAME:SCR>>>User'SCR'>>> user = Raw_input ("Enter your name:") Enter your name:123>>>User'123'>>> user = input ("Enter your name,please!") Enter your name,please!4>>>User4>>> user = input ("Enter your name,please!") Enter your name,please!"SCR">>>User'SCR'>>> user = input ("Enter your name,please!") Enter your name,please!Scrtraceback (most recent): File"<pyshell#67>", line1,inch<module>User= Input ("Enter your name,please!") File"<string>", line1,inch<module>Nameerror:name'SCR' isNot defined>>>
Summarize:
Raw_input more in line with user input habits, the conversion of any user input into a string storage, in the need of other types of data, call the corresponding function to convert;
Input user inputs What to store what, so the user input must conform to the Python syntax requirements, otherwise there will be an error, such as
>>> user = input ("Enter your name,please!") Enter your name,please!Scrtraceback (most recent): File"<pyshell#67>", line1,inch<module>User= Input ("Enter your name,please!") File"<string>", line1,inch<module>Nameerror:name'SCR' isNot defined>>>
The difference between Python input and the Raw_input function