私は単語のリストを持っています。私は最小の長さを持っていない単語を除外したいと思います。フィルターをかけましたが、何らかのエラーが表示されました。フィルタを使用するときに関数に2つの引数を渡す
from functools import partial
z = filter(partial(words_to_integer, y=minimumlength), listofwords)
partial(words_to_integer, y=minimumlength)
はwords_to_integer
と同じ機能ですが、引数y
でminimumlength
に固定されている:私のコードは、エラーがあなたがfunctools.partial
をご覧ください
z = list(filter(words_to_integer,(listofwords,minimumlength)))
TypeError: words_to_integer() missing 1 required positional argument: 'y'