introduction
標準入力の備忘録です。こっちのほうがもっといいよ!ってのがあったらぜひ教えてください。
Inputs
line: 1行
input: 1つのみ (str/int)
input.py
S = input()
N = int(input())
console
string
9999
input: 2以上 (str/int)
input.py
S1, S2 = input().split()
S = input().split()
N1, N2 = map(int, input().split())
N = list(map(int, input().split())
Sunny Rainy
Sunny Rainy Cloudy => ["Sunny", "Rainy", "Cloudy"]
9999 8888
7777 6666 5555 => [7777, 6666, 5555]
line: 2行以上
input: 改行系複数入力 (str/int)
input.py
N = int(input())
S = [input() for _ in range(N)]
N = [int(input()) for _ in range(N)]
3 ... N(行数)
aa
bc
io => ["aa", "bc", "io"]
3
2
9 => [3, 2, 9]
input: 行列
input.py
N = int(input())
S = [input().split() for _ in range(N)]
3
aa bc 82 00 2w
oe jj ed 2s pw
12 de co 99 jd
=> [['aa', 'bc', '82', '00', '2w'], ['oe', 'jj', 'ed', '2s', 'pw'], ['12', 'de', 'co', '99', 'jd']]
input: 改行系複数数値入力 out: 2次元配列
input.py
N = int(input())
S = [[int(i) for i in input().strip()] for _ in range(N)]
3
123456
789012
345678
=> [[1, 2, 3, 4, 5, 6], [7, 8, 9, 0, 1, 2], [3, 4, 5, 6, 7, 8]]