2017-12-27 26 views
-8

我在阅读一行中的变量时遇到了问题。当我知道变量的数量时,我使用了一个map(int, input().splite()),但在这种情况下,在每次运行的代码中,这个数字都是不同的。 (Python 3中)在一行中输入变量

+0

'list(map(int,input()。strip()。split()))'这就是你想要的吗? –

+0

代码示例如何? – noamgot

回答

0

你好你可以试试

runs = 10 # some value you can inpt with int(input("Enter runs: ")) 
values = [] 

for i in range(runs): 
    values.append(input("enter the "+str(i)+". variable: ")) 

这将创建像一个数组:

["10", "32", "hello", "world", "23", "bye"] 

,但我觉得没有办法在一个行做..