Differences between Python raw_input and input in version 2 and Version 3

Source: Internet
Author: User
  Python 2.3.4 (#1, Feb 2 2005, 11:44:13) [GCC 3.4.3 20041212 (Red Hat 3.4.3-9. EL4)] on linux2type "help", "Copyright", "Credits" or "License" for more information. >>> user = raw_input ("Please input:") Please input: Wei # raw_input string succeeded >>> user 'wei' >>> user = input ("Please input :") please input: 123 # The input number is successfully entered (the number is returned) >>> user123 >>> user = Raw_input ("Please input:") Please input: 111   # raw_input: The number is successfully input (returned as a string) >>> user '000000' >>> user = input (" Please input :") please input: Wei # traceback (most recent call last): file "
   
    ", line 1, in? File "
    
     ", line 0, in? Nameerror: Name 'wei' is not defined 
    
    

Python 2.7.3 same as above


In Python 3.2.3, the input and raw_input are integrated, without raw_input.

Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32type "help", "Copyright ", "Credits" or "License" for more information. >>> user = raw_input ("Please input:") # raw_inputtraceback (most recent call last): file "<stdin>", line 1, in <module> nameerror: name 'raw _ input' is not defined >>> user = input ("Please input:") Please input: wei >>> user 'wei' >>> user = input ("Please input:") # The output result of input is as the string please input: 123 >>> user '123'


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.