Python Input Summary

Source: Internet
Author: User

Input summary in Python 2

1.raw_input (prompt = none) with input (prompt = none)

Two are the default parameter types, which can be passed in a string that is used for input when output, such as

1 # Well, your name is really a good movie . 2 your_name = input (" your name is?") ")

Input assumes that the user entered a valid Python expression , and therefore tries to evaluate the expression, input first calls Raw_input to get the original input, and then calls Eval to get the value of the input expression, and if the expression is illegal, an error is thrown. The specific error depends on the input.

In the official documentation for Python 2, there is one sentence: Consider using the Raw_input () function for general input from users. Therefore, unless specifically required, the raw_input of Python 2 should be used primarily as a generic interactive input.

The return type of Raw_input () is a string, and we can combine a function such as int (), float () to convert the string to the format we want

about how to view documents

On Linux, we can type

Pydoc Raw_input

To get a document about Raw_input, and press Q to exit

On Windows, we type

Python-m Pydoc Raw_input

You can get the document without pressing Q to exit

Python Input Summary

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.