我有两个列表
a = ['Shri Vatsav Ltd','Paytm Pvt ltd','Paypal ltd']
b = ['Shri Vatsav Ltd 123 HAL 2nd Stage Indiranagar Banagalore 560008','Paytm Pvt ltd 143 Jallianwallabagh Mumbai India 34567','Paypal ltd 345 Greenwood drive 123ST Long Beach CA 34566 US']
我只需要从列表中提取地址"b"使用list "a"例如,某种交点或类似的东西。并将其存储为名为"c">
的列表请查看示例输出:
输出['123 HAL 2nd Stage Indiranagar Banagalore 560008','143 Jallianwallabagh Mumbai India 3456','345 Greenwood drive 123ST Long Beach CA 34566 US']
谢谢。
a = ['Shri Vatsav Ltd', 'Paytm Pvt ltd', 'Paypal ltd']
b = ['Shri Vatsav Ltd 123 HAL 2nd Stage Indiranagar Banagalore 560008','Paytm Pvt ltd 143 Jallianwallabagh Mumbai India 34567','Paypal ltd 345 Greenwood drive 123ST Long Beach CA 34566 US']
c = [i.replace(j, "") for i in b for j in a if j in i]
print(c) # [' 123 HAL 2nd Stage Indiranagar Banagalore 560008', ' 143 Jallianwallabagh Mumbai India 34567', ' 345 Greenwood drive 123ST Long Beach CA 34566 US']