【发布时间】:2009-09-09 06:19:59
【问题描述】:
我想从标准输入读取五个数字,输入如下:
3、4、5、1、8
分成单独的变量 a、b、c、d 和 e。
我如何在 python 中做到这一点?
我试过了:
import string
a=input()
b=a.split(', ')
对于两个整数,但它不起作用。我明白了:
Traceback (most recent call last):
File "C:\Users\Desktop\comb.py", line 3, in <module>
b=a.split(', ')
AttributeError: 'tuple' object has no attribute 'split'
如何做到这一点?并假设我没有一个固定的,而是一个可变的 n 个整数。然后呢?
【问题讨论】: