The difference between Python input () and raw_input ()

Source: Internet
Author: User

The difference is that raw_input () randomly loses is a string, and input () must follow the Python rules ~

Raw_input ()
Name=raw_input ( ' input name:')age =raw_input (' input ages ')

We enter the age of the names and numbers of Chinese characters

input Name: Xu Song input age:31***repl closed***

Direct loss, effect of the ~ but pay attention to Oh, your age is the format of string oh??

Input ()
Name=input (' input name:')age =input (' input Ages:')

We still enter the names of Chinese characters and the age of the numbers

Enter name:' Xu Song ' input Age:31***repl closed***

The effect is also a leverage ~ but notice? Input () entered strictly according to the Python syntax, is the character on the self-consciously add ', the number is the number ~

When to use Raw_input () when to use input ()?

Characters can be used Raw_input (), of course, not afraid of trouble can also use input () manually add '

int type is best used when input ()

In a Word ~ you read it and write it ~

The difference between Python input () and raw_input ()

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.