以下两段代码有什么区别:

时间:2020-09-10 13:27:27

标签: python

第一个在other_pipes列表中使用星号:

nlp = spacy.load("en")
other_pipes = [pipe for pipe in nlp.pipe_names if pipe != "ner"]
nlp.disable_pipes(other_pipes)

但是其他人却没有:

nlp = spacy.load("en")
other_pipes = [pipe for pipe in nlp.pipe_names if pipe != "ner"]
nlp.disable_pipes(*other_pipes)

即使它们有相似的输出:

第一:

[('tagger', <spacy.pipeline.pipes.Tagger at 0x2103ab55c88>),
 ('parser', <spacy.pipeline.pipes.DependencyParser at 0x2103a84cc48>)]

第二:

[('tagger', <spacy.pipeline.pipes.Tagger at 0x222faa86cc8>),
 ('parser', <spacy.pipeline.pipes.DependencyParser at 0x222f97bcca8>)]

0 个答案:

没有答案