擅长:python、mysql、java
<p>不使用正则表达式怎么样?</p>
<pre class="lang-py prettyprint-override"><code>if string.startswith("ftp://") and string.endswith(".jpg"):
</code></pre>
<p>你不觉得这样读起来更好吗?</p>
<p>您还可以支持多种开始和结束选项:</p>
<pre><code>if (string.startswith(("ftp://", "http://")) and
string.endswith((".jpg", ".png"))):
</code></pre>