如何在 Python 中从字符串和字符串列表创建元组?
pythonserver side programmingprogramming更新于 2025/7/10 10:20:17
内置函数 tuple() 将 Python 字符串转换为单个字符的元组。它还将列表对象转换为元组。
>>> tuple("TutorialsPoint")
('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)
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

