a = ['in 1978 by', 'History', 'members', 'albums', 'June 4th, 1979', 'October 7,1986): "The Lounge', 'In 1984 the', 'early 1990s; prominent']
上面的列表有一些单词,比如历史,成员中没有数字,所以我想删除它们
# output would be
a = ['in 1978 by', 'June 4th, 1979', 'October 7, 1986', 'In 1984 the', 'early 1990s; prominent']
使用正则表达式和列表理解,这是一行:
保留你想要的:
下面是一个较短的替代方法,使用
any()
和string.digits
:相关问题 更多 >
编程相关推荐