元组和列表可以互相转化


1、tuple----------->list():


  >>> t         
(1, '23', [123, 'abc'], ('python', 'learn'))
>>> tls = list(t)                           #tuple-->list
>>> tls
[1, '23', [123, 'abc'], ('python', 'learn')]

2、list------------->tuple():
>>> t_tuple = tuple(tls)                    #list-->tuple
>>> t_tuple
(1, '23', [123, 'abc'], ('python', 'learn'))

你可能感兴趣的:(Python学习)