lambda用法
將函數(shù)轉(zhuǎn)化為表達(dá)式
g = lambda x:x+1
def g(x):
return x+1
map用法
proxys = list(map(lambda x: x.strip(), [y for y in lines]))
set()集合
set() 函數(shù)創(chuàng)建一個(gè)無序不重復(fù)元素集;可進(jìn)行關(guān)系測(cè)試,刪除重復(fù)數(shù)據(jù)苛茂,還可以計(jì)算交集、差集鸠窗、并集等妓羊。
將序列轉(zhuǎn)化為set
crawl_ID = set([list])
交集并集差集
>>> x & y # 交集
set(['o'])
>>> x | y # 并集
set(['b', 'e', 'g', 'l', 'o', 'n', 'r', 'u'])
>>> x - y # 差集
set(['r', 'b', 'u', 'n'])
成員關(guān)系
if ID not in self.temp_ID:
self.temp_id_process(ID)
if ID not in self.finish_ID:
self.crawl_ID.add(ID)