python-讀取多行輸入

 input:

4 3 2
1 2
1 2 
1 2
1 2
3 4
3 4
3 4
#讀取一個數組
n, m = map(int, input().split()) # taking number of rows and column
array = numpy.array([input().strip().split() for _ in range(n)], int)

#讀取兩個數組

x=[]
while True: 
    try:
        line = input()
        if not line: # If line is blank 
            break
        else: 
            x.append(list(map(int,line.strip().split(' '))))
    except EOFError:
        break
        

a=np.array(x[1:x[0][0]+1],dtype=int)
b=np.array(x[x[0][0]+1:x[0][0]+x[0][1]+1],dtype=int)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章