看板 [ Python ]
討論串[問題] 如何將dict的values取set
共 8 篇文章
首頁
上一頁
1
2
下一頁
尾頁

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者timTan (用口頭禪區分年記)時間13年前 (2012/02/21 01:27), 編輯資訊
0
0
0
內容預覽:
map, reduce, filter 的結果,全部都先加上 list吧。. e.g.. var_a = list(reduce(lambda x,y: x.intersection(y), s)). print(var_a). --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From:

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者kadodo (想辦法突破)時間13年前 (2012/02/20 23:03), 編輯資訊
0
0
0
內容預覽:
再請教一下 如果我寫法並沒有先print出來 而是直接先存到var_a, 之後再印出來:. s=map(lambda x : set(x), target.values()). var_a = reduce(lambda x,y: x.intersection(y), s). print(var_a

推噓0(0推 0噓 1→)留言1則,0人參與, 最新作者mikapauli (cablin)時間13年前 (2012/02/20 22:14), 編輯資訊
0
0
0
內容預覽:
為此特地去下載3.2.2後我大概知道問題在那了... 你的寫法應該是. s=map(lambda x : set(x), target.values()). print(reduce(lambda x,y: x.intersection(y), s)). var_a = reduce(lambda
(還有41個字)

推噓4(4推 0噓 9→)留言13則,0人參與, 最新作者mikapauli (cablin)時間13年前 (2012/02/20 21:46), 編輯資訊
0
0
0
內容預覽:
建議你把完整的code從頭到尾貼上來,或是直接找個空間上傳你的檔案. 另外. (lambda x: set(x))==set. (lambda x,y: x.intersection(y))==set.intersection. 這裡用lambda非常多餘. 加上set.intersection本身

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者kadodo (想辦法突破)時間13年前 (2012/02/20 19:24), 編輯資訊
0
0
0
內容預覽:
s=map(lambda x : set(x), target.values()). print(reduce(lambda x,y: x.intersection(y), s)). 以上這樣OK 有PRINT出正確結果. s=map(lambda x : set(x), target.values
(還有113個字)
首頁
上一頁
1
2
下一頁
尾頁