[英]how to convert list into tuple in python , all elements of list should be in int?
use proper example for clarification使用适当的例子进行说明
I need solution through code list tuple w我需要通过代码列表元组 w 解决方案
list should be changed in tuple int first then convert into tuple列表应该首先在元组 int 中更改,然后转换为元组
_list = [1, 2, 3, "hello", "world"]
_tuple = tuple(_list)
l = ["1", "2", "3", "4"]
l_int = [int(i) for i in l] # Convert everything to int one by one and save in new list to later convert to tuple
t = tuple(l_int)
Like this?像这样?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.