Skip to main content
 首页 » 编程设计

python之在 Python 中将列表转换为元组

2025年05月04日14telwanggs

<分区>

>>> list=['a','b'] 
>>> tuple=tuple(list) 
>>> list.append('a') 
>>> print(tuple) 
('a', 'b') 
>>> another_tuple=tuple(list) 
Traceback (most recent call last): 
  File "<stdin>", line 1, in <module> 
TypeError: 'tuple' object is not callable 

为什么我不能将列表“列表”转换为元组?