如何在python中的单行中获取多个输入

时间:2017-03-31 03:20:09

标签: python

我正在使用list comphrensions:

x = [i for i in int(raw_input("Enter Input:")).split(",")]
Enter Input : 1 2 3 4 5

但它会引发错误:

Traceback (most recent call last):
File "python", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1 2 3 4 5'

有人可以把它整理出来。

1 个答案:

答案 0 :(得分:1)

x = [int(i) for i in raw_input("Enter Input:").split(" ")]