Python function-input ()

Source: Internet
Author: User

input([prompt])

If [prompt] is present, it is written to the standard output without a line break. The function then reads the input, converts it to a string, and then returns.

1 >>> s = input (")  2 ---Monty Python'  s Flying Circus3 >>> s  4"Monty Python ' s Flying Circus"

Add:

Explanation of Python version 2.x:

Input and raw_input can be used to read the console inputs, but input and raw_input are different when working with numbers

When the input is a pure number:

Input returns a numeric type, such as Int,float
Raw_inpout return String type, String type

Input string is an expression

Input computes the numeric expression in the string, and Raw_input does not.

If you enter "57 + 3":

Input will get an integer 60

Raw_input will get the string "57 + 3"

Implementation of Python input

Look at the Python input document, you can see that input is actually implemented through raw_input, the principle is very simple, the following line of code:

1 def input (Prompt): 2     return (eval (raw_input (prompt)))

Python function-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.