我使用Python和函数给我这个输出:
[['2', 'prod1', 'Ela - Available'], ['2', 'prod1', 'Base - Replication logs']]
我的目标是删除所有包含"可用"用Python
所以我的目标是:
[['2', 'prod1', 'Base - Replication logs']]
答案 0 :(得分:4)
>>> l = [['2', 'prod1', 'Ela - Available'], ['2', 'prod1', 'Base - Replication logs']]
>>> filter(lambda x: not any('Available' in y for y in x), l)
[['2', 'prod1', 'Base - Replication logs']]
答案 1 :(得分:4)
试试这个:
data = [['2', 'prod1', 'Ela - Available'], ['2', 'prod1', 'Base - Replication logs']]
output = [line for line in data if not 'Available' in str(line)]
print(output)
[['2', 'prod1', 'Base - Replication logs']]