L = ['abc', 'day', 'ghi']
res = [i.find('a') for i in L]
# [0, 1, -1]
如文件所述:
Return the lowest index in the string where substring sub is found
within the slice s[start:end]. Optional arguments start and end are
interpreted as in slice notation. Return -1 if sub is not found.
您可以将^{} 用于列表理解:
如文件所述:
或带索引
相关问题 更多 >
编程相关推荐