Finding in elements in a tuple and filtering them

后端 未结 5 2067
借酒劲吻你
借酒劲吻你 2020-11-30 10:23

Assuming I have a tuple like:

[(\'text-1\',\'xxx\'), (\'img-1\',\'iii\'), (\'img-2\',\'jjj\'), (\'text-2\',\'xxx\')]

I want to filter out t

5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 11:08

    tuple_filter = lambda t, i, w: filter(lambda a: a[i].startswith(w), t)
    newtuple = tuple_filter(thetuple, 0, 'img')
    

提交回复
热议问题