私は python itertools を学ぼうとしています (今のところ気に入っています!) が、問題が発生しました。次の 2 つのリストがあります。
a=["http://www.xyz.com/jhuh7287", "http://www.hjuk.com/kashjh716", "http://www.psudjg.com/9279jshkoh", "http://www.xyz.com/jhuh7287", "http://www.xyz.com/9289jhjbg"]
data=["k","some small string here", "so med string here", "some string here","l"]
tempstring="http://www.xyz.com"
最初に、私が望んでいたのは、特定の長さを下回るすべての文字列の data[i] を削除し、その後 a. このために、次のようなものを使用しました。
iselectors = [x is not len(str(x))>1 for x in data]
data=list(itertools.compress(data, iselectors))
a=list(itertools.compress(a, selectors))
..これはうまくいきます。ここで、iselector に別の条件を追加する必要があります。これは、「tempstring が a[i] にある」場合と len(str(x))>1..
だから、私は次のようなことを試しました:
iselectors = [tempstring in a and x is not len(str(x))>1 for x in data]
...しかし、「tempstring in a」を使用するときに a 全体を反復しているとは思わないため、これが正しいかどうかはわかりません
どんなガイダンスでも大歓迎です。ありがとう。