LoginSignup
0
0

More than 5 years have passed since last update.

Pythonで標準入力からデータを受け取る

Posted at

fileinputモジュールを使います。

import fileinput

for line in fileinput.input():
    print(line,end="")

以下のどの呼び出し方でも、使えます。ファイルの中身を表示するだけの例なので、あまり面白くはないですが(^^;

python3 test.py test.py 
python3 test.py < test.py
cat test.py | python3 test.py
0
0
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
0
0