2024-04-29 13:36:17 发布
网友
我想从下面的字符串中找到所有单词'quick'。你知道吗
myString = ''' hi quick is qui ck is some thing is very big and quick is it has got some backend quic k '''
我的密码。你知道吗
In [39]: re.findall('quick',myString , re.M) Out[39]: ['quick', 'quick']
字符串包括换行符和这些行末尾的空格。删除它们,然后使用命令处理字符串:
s = ''.join([line.rstrip() for line in myString.splitlines()]) re.findall('quick', s, re.M)
字符串包括换行符和这些行末尾的空格。删除它们,然后使用命令处理字符串:
相关问题 更多 >
编程相关推荐