我正在使用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'
有人可以把它整理出来。
答案 0 :(得分:1)
x = [int(i) for i in raw_input("Enter Input:").split(" ")]