0
1

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 1 year has passed since last update.

Pythonで標準入出力

Posted at

覚書です。

入力

1行にひとつ

# 文字列
s = input()

# 整数
n = int(input())

1行に複数(空白区切り)

# 文字列
str_list = input().split()      # 配列
s1, s2, s3 = input().split()    # 分解

# 数列
num_list = list(map(int, input().split()))  # 配列
n1, n2, n3 = map(int, input().split())      # 分解

複数行にひとつ

cnt = 3     #取得する要素数。今回は3つとする

# 文字列
str_list = [input() for _ in range(cnt)]

# 数列
num_list = [int(input()) for _ in range(cnt)]

複数行に複数

cnt = 3     #取得する行数。今回は3つとする

# 文字列
str_list = [input().split() for _ in range(cnt)]

# 数列
num_list = [list(map(int, input().split())) for _ in range(cnt)]

出力

一行に一つ

print(out)

一行に複数(スペース区切り)

print(f"{o1} {o2} {o3}")
print(*out)     # outは配列

複数行にひとつ

for i in out:     # outは配列
    print(i)

複数行に複数

for i in out:     # outは二次元配列
    print(*i)
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?