Log on the blog only to find that has been registered for a year, because before has been not intended to engage in software development industry, so blog is shelved, software development, for me, is the growth, but also temper. Brainstorming is always about being free, documenting inspiration, and sharing the fruits of thought progress with everyone.
Python language, many people think very simple, I do not deny that the introduction is really easy, but to achieve mastery, or need precipitation, accumulation. For small partners who want to learn python, the difference between the input () and the Raw_input () may not be very clear and confusing, of course, if you are using the python3.x version, you certainly don't have to consider what input () differs from Raw_input (). Because the python3.x version has discarded raw_input (), only input (), but input () has its limitations, and if you use the python2.x version, then you should consider the difference between the two. Talk less, get to the chase!
1 x=raw_input ( " please input A number: ) 2 y=raw_input ( please input a number: ) if x>=y: 4 x 5 else : 6 print y
The code compares the size of the two numbers and outputs the larger one, but when the input x=23,y=100, the output is 23;x=3456,y=20000 and the output number is 3456. Why is it? OK, Next we use input () to replace raw_input (), continue to run the code, input x=23,y=100, the output is 100;x=3456,y=20000, the output is 20000, the result is finally right, but why use Raw_input ( Is it going to go wrong? The main reason is: the use of raw_input () input, you can enter characters and numbers for comparison, the fundamental comparison is to compare the ASCII value of the two, so when the input x=23,y=100, the computer will be in order one by one to compare the ASCII code value, That's why the output is 23. The input () in the Raw_input () and python3.x versions of the python2.x version is the same, can accept the string input, and the python2.x version only accepts Arabic numerals, and an error is entered into the string.
The difference between the input () and the Raw_input () of the Python introductory learning