Python:如何将输入的数字转换为列表?

1.code

numb1 = input('输入数字:').split()
print(numb1)
numb2 = list(map(int, numb1))
print(numb2)

2.result

输入数字:1 2 3 54
['1', '2', '3', '54']
[1, 2, 3, 54]

猜你喜欢

转载自blog.csdn.net/qq_40797015/article/details/112171892