簡體   English   中英

Python將兩個列表合並為兩個元組的元組

[英]Python merge two lists into tuple of two tuples

我想將兩個列表合並成兩個元組的元組

lst1 = [1,2,3,4,5]
lst2 = ['one','two','three','four','five']

所需的輸出:

tup_of_2_tups = ((1,'one'),(2,'two'),(3,'three'),
                 (4,'four'),(5,'five'))

歸功於@WillemVanOnsem:

output = tuple(zip(lst1,lst2))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM