如何在Python字符串列表中查找出指定字符所在字符串

如题所述

第1个回答  2016-12-15
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']

本回答被提问者采纳
第2个回答  2016-12-15
>>> a = 'hello'
>>> a.index('h')
0
>>>

相似回答