sys读入的时候会把换行符也读进去
1028
没想到办法怎么在不产生列表的前提下直接进行未知数量的切片存取,用re可能可以。
import sys n = int(input()) low = 100 high = 0 lowotp = '' highotp = '' for i in range(n): s = sys.stdin.readline()#readline的字符串后面跟了一个/n sl = s.split(' ')#先用split做吧 if int(sl[-1])<low: low = int(sl[-1]) lowotp = s if int(sl[-1])>high: high = int(sl[-1]) highotp = s h1 = highotp.split(' ') l1 = lowotp.split(' ') print(' '.join(h1[0:2])) print(' '.join(l1[0:2]))