【发布时间】:2012-09-24 16:39:58
【问题描述】:
我目前有这个:
c = eval(input("Enter a group of numbers "))
#say someone types 123
print (c)
#prints out 123
我想要这个:
c = eval(input("Enter a group of numbers "))
#say they enter 123
print (c)
#prints out [1,2,3]
我希望 123 最终成为 [1,2,3]。我该怎么做?
【问题讨论】:
-
不要使用
eval。另外,如果您使用的是 python 2,请不要使用input。两者都会导致任意代码执行漏洞。 -
我知道每个人都喜欢简单的代表,但是对于高质量的问答,常见问题确实需要关闭,而不是每次都用十几个相同的答案来回答。
标签: python