擅长:python、mysql、java
<p>这里有一个解决方案:</p>
<pre><code>import itertools
def task(kw,text):
i = itertools.cycle(kw)
return tuple(next(i)+t if t.isalpha() else t for t in text)
print(task('lemon','hi there!'))
</code></pre>
<h3>输出</h3>
^{pr2}$
<p><a href="http://docs.python.org/library/itertools.html#itertools.cycle" rel="nofollow">itertools.cycle</a>重复遍历一个序列(字符串是一个字符序列)。<a href="http://docs.python.org/library/functions.html#next" rel="nofollow">next</a>从重复序列中获取下一个字符。如果文本字符是字母,<a href="http://docs.python.org/reference/expressions.html#generator-expressions" rel="nofollow">generator expression</a>选择下一个关键字字母和文本字符对,否则它只选择非字母字符。在</p>