Skip to main content
 首页 » 编程设计

python之从 Python 中的输入创建元组

2025年05月04日9wayfarer

这是我的例子:

>>> a=input ('some text : ')  # value entered is 1,1 
>>> print (a) 
1,1 

结果我想要一个元组 (1, 1)

我该怎么做?

请您参考如下方法:

你可以做类似的事情

a = tuple(int(x) for x in a.split(","))