擅长:python、mysql、java
<p>您可以将<a href="https://docs.python.org/3/library/stdtypes.html#str.find" rel="noreferrer">^{<cd1>}</a>用于列表理解:</p>
<pre><code>L = ['abc', 'day', 'ghi']
res = [i.find('a') for i in L]
# [0, 1, -1]
</code></pre>
<p>如文件所述:</p>
<blockquote>
<p>Return the lowest index in the string where substring <code>sub</code> is found
within the slice <code>s[start:end]</code>. Optional arguments <code>start</code> and <code>end</code> are
interpreted as in slice notation. Return <code>-1</code> if <code>sub</code> is not found.</p>
</blockquote>