如何在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']
温馨提示:答案为网友推荐,仅供参考
相似回答