Python 即使用户输入了0,列表仍将继续打印
即使用户输入的输入值为0,列表也不会退出。您的输入值是字符串而不是数字 尝试将其转换为整数或将其转换为整数 试试这个Python 即使用户输入了0,列表仍将继续打印,python,python-2.7,input,type-conversion,Python,Python 2.7,Input,Type Conversion,即使用户输入的输入值为0,列表也不会退出。您的输入值是字符串而不是数字 尝试将其转换为整数或将其转换为整数 试试这个 end = False numbers = [] while not end: i =(raw_input(" Enter the number(0 to end the input)")) if i ==0: end = True else: numbers.append(i) print numbers 或者把你的意见作为 if int(i) == 0
end = False
numbers = []
while not end:
i =(raw_input(" Enter the number(0 to end the input)"))
if i ==0:
end = True
else:
numbers.append(i)
print numbers
或者把你的意见作为
if int(i) == 0
i =(input(" Enter the number(0 to end the input)"))