Home > Backend Development > Python Tutorial > How to read stdin in Python

How to read stdin in Python

silencement
Release: 2019-05-25 15:50:26
Original
6140 people have browsed it

How to read stdin in Python

Two standardized input methods commonly used in Python: sys.stdin and input respectively. The two methods of use are roughly the same, but in general, the use of sys.stdin To be more diverse, the following examples illustrate the differences between the two.

1. Input input

Input input is very simple, just get User input is usually in the console interface.

How to read stdin in Python

After running, you can wait for user input. Eventually, the system will consider the Enter key to end the input.

2. sys.stdin input

First, it can also achieve the same function as input, such as

How to read stdin in Python

However, it is more commonly used in another way. You can directly use the file as the overall input, which can be easily concise.

How to read stdin in Python

#Usage method, it is very convenient to redirect the file to the input.

How to read stdin in Python

The above is the detailed content of How to read stdin in Python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template