擅长:python、mysql、java
<pre><code>link = "http://advert.com/go/2/12345/0/http://truelink.com/football/abcde.html?"
link[link.rfind("http://"):]
</code></pre>
<p>退货:</p>
<pre><code>"http://truelink.com/football/abcde.html?"
</code></pre>
<p>这就是我要做的。<code>rfind</code>查找最后出现的“http”并返回索引。
在您的示例中,这种情况显然是真实的、原始的url。然后可以提取从该索引开始到结束的子字符串。你知道吗</p>
<p>因此,如果您有一些字符串<code>myStr</code>,则在python中使用类似数组的表达式提取子字符串:</p>
<pre><code>myStr[0] # returns the first character
myStr[0:5] # returns the first 5 letters, so that 0 <= characterIndex < 5
myStr[5:] # returns all characters from index 5 to the end of the string
myStr[:5] # is the same like myStr[0:5]
</code></pre>