如何在Python中根据字符串和字符串列表创建元组?

内置函数tuple()将Python字符串转换为单个字符的元组。它还将列表对象转换为元组。

>>> tuple("nhooo")
('T', 'u', 't', 'o', 'r', 'i', 'a', 'l', 's', 'P', 'o', 'i', 'n', 't')
>>> L1=[45, 32, 100, 10, 24, 56]
>>> tuple(L1)
(45, 32, 100, 10, 24, 56)