1 多行等长输出
while True:
try:
l = list(map(int, input().split()))
print(sum(l))
except:
break
2 多行不等长输出
while True:
try:
l = list(map(int, input().split()))
if len(l) != 1:
print(sum(i))
else:
pass
except:
break
3 多行输入,遇00停止
while True:
try:
a, b = map(int, input().split())
if a == 0 and b == 0:
break
else:
print(a+b)
except:
break
4 多行输入,遇0停止
while True:
try:
l = list(map(int, input().split()))
if l[0] == 0:
break
else:
print(sum(l))
except:
break
5 先输入行数,再输入各行
while True:
try:
n = int(input())
for i in range(n):
l = list(map(int, input().split()))
print(sum(nums[1:]))
except:
break
6 每行第一个数为数据个数
while True:
try:
l = list(map(int, input().split()))
print(sum(l[1:]))
except:
break
7 输入为字符串型整型
while True:
try:
l = list(map(int, input().strip().split()))
print(sum(nums))
except:
break
8 首行为字符串个数,第二行为空格空开的字符串
while True:
try:
n = int(input())
l = list(map(str, input().strip().split()))
print(" ".join(l))
except:
break
9 多行字符串输入
while True:
try:
l = list(map(str, input().strip().split()))
l.sort()
print(" ".join(l))
except:
break
10 多行字符串输入
while True:
try:
l = list(map(str, input().strip().split()))
l.sort()
print(".".join(l))
except:
break
总结
其实很简单:
list
map
sort
join
input
就是上面几个函数用法哦,记住重点就能写出来。