0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

競技プログラミングにおける標準入力の受け取り方

Last updated at Posted at 2020-06-22

競技プログラミングでは、標準入力を受け取る機会が多いが、それの受け取り方を備忘録として残しておく。

input.txt
Hoge
sample.py
from sys import stdin

a = stdin.readline().rstrip()
print(a.upper())    # 読み込んだ文字を大文字に変換

の2つのファイルを作成し、ターミナルで以下を実行する。

python sample.py < input.txt

すると、

HOGE

が返ってくる。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?