1. python2.7的标准输入输出
n = eval(raw_input())
total_list = list()
for i in range(n):
a,b = raw_input().split()
temp_list = list()
temp_list.append(a)
temp_list.append(b)
total_list.append(temp_list)
row = len(total_list)
col = len(total_list[0])
for i in range(row):
row_list = total_list[i]
for j in range(col):
print row_list[j],
print
2. python3.4的标准输入输出
n = eval(input())
total_list = list()
for i in range(n):
a,b = input().split()
temp_list = list()
temp_list.append(a)
temp_list.append(b)
total_list.append(temp_list)
row = len(total_list)
col = len(total_list[0])
for i in range(row):
row_list = total_list[i]
for j in range(col):
print(row_list[j],end = " ")
print()
参考:《python学习手册》311-314页
本文提供了Python2.7和Python3.4中标准输入输出的具体实现示例,通过构建列表来处理多次输入,并展示如何根据不同Python版本进行相应的代码调整。
588

被折叠的 条评论
为什么被折叠?



