看板 Python 關於我們 聯絡資訊
請問一下 同標題 要怎麼從list中 找出整數 我想要實現 如果我的list是這樣 [usa, aaa, bbb, ccc, 0, 40,....] 我想要抓出 0 -----> i+1:0 請問我應該要怎麼寫這判斷式 我現在是使用 for xxx in 'usa' 這種去找 但是我抓不到integer 如果有違反版規的話 請告訴我我會刪掉 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.41.129 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1416033388.A.076.html
flarehunter: "我想要抓出 0 -----> i+1:0" 這是什麼意思? 11/15 14:47
chickdcing: 意思是說我要抓出這個數字 放在新的list中 11/15 14:47
chickdcing: 如果是第i項抓到0 放到新的list中變i+1:0 11/15 14:48
secondsee: blist = [e for e in alist if type(e)==int] 11/15 14:52
chickdcing: 如果數字是random呢? 就是我無法確定是哪些的話 11/15 14:53
goldflower: 不太懂 上面的方法是不是random有差嗎@@ 11/16 00:57
chickdcing: 我懂了 哈哈哈 謝謝大家 11/16 01:20
panpass: [u"{}:{}".format(i+1, n) for i, n in enumerate(\ 12/03 03:00
panpass: yourlist) if n.isdigit() and u"." not in n] 12/03 03:03