首页 > 解决方案 > 是否可以从python中的集合中丢弃数字字符串(仅包含数字的字符串)?

问题描述

例如,集合是:

{'abc', '123', 'efg', 'er23'}

我想只删除集合中的“123”。在python中可能吗?

标签: pythonset

解决方案


尝试:

s={'abc', '123', 'efg', 'er23'}
print({i for i in s if not i.isdigit()})

推荐阅读