擅长:python、mysql、java
<p>您可以在此处使用<a href="https://docs.python.org/3.6/library/functions.html#zip" rel="nofollow noreferrer">^{<cd1>}</a>获得每两个子字符串:</p>
<pre><code>>>> string = 'AAAATTTTATATATAT'
>>> ','.join(x + y for x, y in zip(string, string[1:]))
'AA,AA,AA,AT,TT,TT,TT,TA,AT,TA,AT,TA,AT,TA,AT'
</code></pre>
<p>这也是另一种方式:</p>
<pre><code>>>> ','.join(map(''.join, zip(string, string[1:])))
'AA,AA,AA,AT,TT,TT,TT,TA,AT,TA,AT,TA,AT,TA,AT'
</code></pre>
<p>甚至像这样:</p>
<pre><code>>>> ','.join(map(lambda x, y: x + y, string, string[1:]))
'AA,AA,AA,AT,TT,TT,TT,TA,AT,TA,AT,TA,AT,TA,AT'
</code></pre>