LoginSignup
3
3

More than 5 years have passed since last update.

[Python] Read From Stdin

Last updated at Posted at 2014-11-12

If you want to read a line from the stdin. Use this:

raw_input()
#or
sys.stdin.readline()

If the value is a integer, float or something else, you should cast the input to the type that you want.

a = int(raw_input())
b = float(raw_input())

if the line have some integers splitted by space such as this:

12 25 37

Then you can do this:

(a, b, c) = map(int, raw_input().split())
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3