[英]how to convert list into tuple in python , all elements of list should be in int?
使用適當的例子進行說明
我需要通過代碼列表元組 w 解決方案
列表應該首先在元組 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)
像這樣?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.