空格改成空字符串
Because you're checking a space, not an emply string in your code, which will be an endless loop.
Consider to change ' ' (space) in the if sentence to '' (emply) to stop that.
给写了两种方法:
s = 0
while True:
n = input()
if not n: #即: if n=='':
break
s += int(n)
print(s)
#或者:
s = 1
while s:
try:
s += int(input())
except:
print(s-1)
break