看板 [ Python ]
討論串[問題] list中的list
共 4 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者tommy5617時間6年前 (2018/09/13 00:20), 編輯資訊
0
0
0
內容預覽:

推噓0(0推 0噓 1→)留言1則,0人參與, 6年前最新作者dianshan (dschen)時間6年前 (2018/09/12 22:56), 編輯資訊
0
0
0
內容預覽:
剛好最近用到,可參考. list2 = sorted(list1, key=lambda x: len(x), reverse=True). from functools import reduce. list3 = reduce(lambda e1, e2: e1 + e2, list1). --

推噓0(0推 0噓 1→)留言1則,0人參與, 6年前最新作者thefattiger (LawTea)時間6年前 (2018/09/12 22:35), 編輯資訊
0
0
0
內容預覽:
list2=sorted(list1,key=lambda l:-len(l)). 想要in place的話可以用list1.sort. list3=[i for l in list1 for i in l]. --. 發信站: 批踢踢實業坊(ptt.cc), 來自: 58.114.212.15

推噓3(3推 0噓 6→)留言9則,0人參與, 6年前最新作者tommy5617 (地瓜YA!)時間6年前 (2018/09/12 22:14), 編輯資訊
0
0
0
內容預覽:
各位大大好. 新手初次提問還請多多指教. 想請問關於list中還有list的問題. list1 = [ [1,2], [3,4,5], [6], [7,8,9,10] ]. 1.我想把裡面的list依照他們的元素多寡重新排序:. list2 = [ [7,8,9,10], [3,4,5], [1,2
(還有33個字)
首頁
上一頁
1
下一頁
尾頁