跟着专注于计算机视觉的AndyJ的妈妈我学算法之每日一题不是leetcode题python标准输入

好久没有写标准输入了。说实话,sys.stdin 那种已经忘了,不过发现好像不是很实用,input()靠谱点。
写一下,回顾回顾。

# 知道有多少行的。
a = input()
res = []
for _ in range(int(a)):
    l = [int(i) for i in input().split(',')]
    res.append(l)
print(res)

# 不知道有多少行,没有输入时break,两个差不多。
res = []
while True:
    a = input()
    if not a:
        break
    l = [int(i) for i in a.split(',')]
    res.append(l)
print(res)

好了。ok。

猜你喜欢

转载自blog.csdn.net/mianjiong2855/article/details/107444109
今日推荐