如何在Python字符串列表中查找出指定字符所在字符串
展开全部
re.findall('\\w*{}\\w*'.format(c),','.join(l))
Python 3.5.2 (default, Dec 7 2016, 23:38:49)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> l=['sfdsd','ddff']
>>> c='s'
>>> re.findall('\\w*{}\\w*'.format(c),','.join(l))
['sfdsd']
Python 3.5.2 (default, Dec 7 2016, 23:38:49)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> l=['sfdsd','ddff']
>>> c='s'
>>> re.findall('\\w*{}\\w*'.format(c),','.join(l))
['sfdsd']
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询