【发布时间】:2021-10-09 09:42:03
【问题描述】:
我有一个从我的网络抓取中附加的输出列表。
for post in get_posts("test", pages=50):
print(post)
listposts.append(post)
实际输出:
{'post_id': '1', 'text': 'abc'}
{'post_id': '2', 'text': 'haha'}
{'post_id': '3', 'text': 'abc'}
{'post_id': '4', 'text': 'haha'}
如何让它只显示 text with abc ? :
预期输出:
{'post_id': '1', 'text': 'abc'}
{'post_id': '3', 'text': 'abc'}
【问题讨论】:
-
这能回答你的问题吗? Filter list of dictionaries
-
这能回答你的问题吗? stackoverflow.com/questions/29051573/…