如何识别字符串列表中的十进制数以删除它们?理想情况下,在单个操作中,content = [x for x in content if not x.isdecimal()]
(遗憾的是,isdecimal()和isnumeric()在这里不起作用)
例如,如果content = ['55', 'line', '0.04', 'show', 'IR', '50.5', 'find', 'among', '0.06', 'also', 'detected', '0.05', 'ratio', 'fashion.sense', '123442b']
我希望输出是content = ['line', 'show', 'IR', 'find', 'among', 'also', 'detected', 'ratio', 'fashion.sense', '123442b']
应使用正则表达式测试字符串是否为十进制:
只需添加Mr Geek答案,您还应该查看Regex上的python文档。在
相关问题 更多 >
编程相关推荐