[Python] Read From Stdin

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())

Recommended Posts

[Python] Read From Stdin
Read and use Python files from Python
Read fbx from python with cinema4d
sql from python
MeCab from Python
[Python] Read command line arguments from file name or stdin
[python] Read data
Use thingsspeak from python
Read DXF in python
Touch MySQL from Python 3
Operate Filemaker from Python
Use fluentd from python
Changes from Python 2 to Python 3.0
Python from or import
Use MySQL from Python
[Python] How to read data from CIFAR-10 and CIFAR-100
Run python from excel
Install python from source
Execute command from Python
Operate neutron from Python!
Use MySQL from Python
Operate LXC from Python
Manipulate riak from python
Force Python from Fortran
Use BigQuery from python.
Execute command from python
Read line by line from a file with Python
Read Python csv file
Use mecab-ipadic-neologd from python
Read QR code from image file with Python (Mac)
Deep Python learned from DEAP
Read csv with python pandas
Grammar features added from Python3.6
Cheating from PHP to Python
OCR from PDF in Python
Use MySQL from Anaconda (python)
Read Euler's formula in Python
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Study from Python Hour4: Object-oriented ②
Query Athena from Lambda Python
Access Oracle DB from Python
Start / stop GCE from python
Read Namespace-specified XML in Python
Stop Omxplayer from Python code
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
Install pyenv from Homebrew, install Python from pyenv
Study from Python Hour4: Object-oriented ①
Python naming convention (from PEP8)
With skype, notify with skype from python!
Read Fortran output in python
Register redmine issue from Python
Read json data with python
Python> Read from a multi-line string instead of a file> io.StringIO ()
Call Matlab from Python to optimize
Execute Python script from batch file
Call a Python function from p5.js.
Python: Exclude tags from html data
Use Stanford Core NLP from Python
Try IAM Database Authentication from Python
Call C from Python with DragonFFI