0
我使用Python和功能給我這個輸出表:Python中如何刪除線
[['2', 'prod1', 'Ela - Available'], ['2', 'prod1', 'Base - Replication logs']]
我的目標是刪除所有行包含「可用」與Python
所以我的目標它有:
[['2', 'prod1', 'Base - Replication logs']]
我使用Python和功能給我這個輸出表:Python中如何刪除線
[['2', 'prod1', 'Ela - Available'], ['2', 'prod1', 'Base - Replication logs']]
我的目標是刪除所有行包含「可用」與Python
所以我的目標它有:
[['2', 'prod1', 'Base - Replication logs']]
試試這個:
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']]
>>> 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']]
你能展示你的嘗試嗎? – EdChum