亚洲精品国产精品乱码视色,下载应用成人电影AVapp,成人影院下载视频

      <track id="gfhue"><i id="gfhue"></i></track><input id="gfhue"></input>

      1. 更多精彩內(nèi)容,歡迎關(guān)注:

        視頻號
        視頻號

        抖音
        抖音

        快手
        快手

        微博
        微博

        python 交集

        文檔

        python 交集

        通過python求交集,除了運用常規(guī)and,還能通過intersection = list(set(a).intersection(b))、intersection = list(set(a) & set(b))等方法實現(xiàn)。
        推薦度:
        導讀通過python求交集,除了運用常規(guī)and,還能通過intersection = list(set(a).intersection(b))、intersection = list(set(a) & set(b))等方法實現(xiàn)。

        python 交集怎么操作?一起來看看小編今天的分享吧!

        在數(shù)據(jù)處理中經(jīng)常需要使用 Python來獲取兩個列表的交集,在 Python 中實現(xiàn)的方法有很多,以下是常用的獲取交集的方法。

        常規(guī)方法如下:

        >>>?a?=?[1,?2,?3,?4,?5,?6]
        >>>?b?=?[2,?4,?6,?8?,10]
        >>>?a?and?b
        [2,?4,?6]

        其他方法如下:

        方法一:

        intersection?=?list(set(a).intersection(b))

        方法二:

        intersection?=?list(set(a)?&?set(b))

        方法三:

        intersection?=?[x?for?x?in?b?if?x?in?set(a)]?#?list?a?is?the?larger?list?b

        方法四:

        intersection?=?list((set(a).union(set(b)))^(set(a)^set(b)))

        注意:如果不考慮順序并且一定要使用 loop 的話,不要直接使用 List,而應(yīng)該使用 Set。在 List 中查找元素相對 Set 慢了非常非常多。

        以上就是小編今天的分享了,希望可以幫助到大家。

        文檔

        python 交集

        通過python求交集,除了運用常規(guī)and,還能通過intersection = list(set(a).intersection(b))、intersection = list(set(a) & set(b))等方法實現(xiàn)。
        推薦度:
        為你推薦
        資訊專欄
        熱門視頻
        相關(guān)推薦
        object 轉(zhuǎn)list object轉(zhuǎn)bigdecimal java get和set方法 python中g(shù)et函數(shù)用法 js set方法 mysql去重復 保留一條 rstudio使用教程 oracle coalesce python configparser模塊 python strip函數(shù) python調(diào)用dll java concat js 遍歷json js json對象 js數(shù)組遍歷方法 python 引用 idea的maven配置 maven安裝配置 java filereader java stream js讀取文件 linux 格式化u盤 deque java java process armoury crate打不開 python skimage vue使用jquery js set去重 python的range函數(shù)用法 vue 調(diào)用子組件方法 java反射獲取屬性值 python中find函數(shù)的用法 getclass方法 python中strip函數(shù)的用法 js class類 mysql time類型 python中sorted函數(shù)的用法 cad的基本命令 ubuntu卸載mysql js獲取隨機數(shù)
        Top